sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

‎SharePoint Updates from Word Online not accurate

Open Kamalasekaran opened this issue 1 year ago • 11 comments

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Developer environment

Windows

What browser(s) / client(s) have you tested

  • [ ] 💥 Internet Explorer
  • [x] 💥 Microsoft Edge
  • [x] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

-Word Online

  • SharePoint Online CSOM Azure function
  • SharePoint Webhook

Describe the bug / error

I’m working on building a SharePoint Webhook integrated with an Azure Function that accesses a SharePoint site using an Azure Entra ID application with the Sites.Selected permission. The goal is to open a SharePoint document in Word Online, edit its content, and then use the SharePoint Webhook to trigger an Azure Function that updates the document’s metadata fields using SystemUpdate(). However, I’ve noticed an issue: if the document remains open in Word Online with AutoSave enabled, the changes made via CSOM seem to get overwritten. I’d like to understand why this is happening and how I can prevent it.

Steps to reproduce

Set Up Azure Entra ID Application:

Register an application in Azure Entra ID.

  1. Configure it with the Sites.Selected Application permission (SharePoint) and grant admin consent. Create an Azure Function:
  2. Develop an Azure Function (e.g., HTTP-triggered) to handle SharePoint Webhook notifications.
  3. Authenticate with SharePoint using the Azure Entra ID application using PnP command Configure SharePoint Webhook: Create a SharePoint document library in a SharePoint Online site. Register a Webhook subscription for the document library, pointing to the Azure Function endpoint. Ensure the Webhook triggers on document changes (e.g., ItemUpdated events). Upload a Test Document: Upload a Word document (e.g., TestDoc.docx) to the SharePoint document library. Edit Document in Word Online: Open TestDoc.docx in Word Online. Enable AutoSave (default behavior in Word Online). Make a content change (e.g., add a sentence) and let AutoSave sync the update. Trigger Metadata Update via Azure Function: Simulate or wait for the SharePoint Webhook to trigger the Azure Function (alternatively, manually invoke the function).
  4. Use CSOM in the Azure Function to update metadata fields of TestDoc.docx (e.g., set a custom field like Status to Updated using SystemUpdate).
  5. Confirm the metadata update reflects in SharePoint. Observe Conflict:
  6. While TestDoc.docx remains open in Word Online with AutoSave active, note that the metadata changes made via CSOM are overwritten or reverted after a short period.
  7. Verify this by refreshing the SharePoint library view or checking the document properties.

Expected behavior

This Happening only with fields updated via SharePoint CSOM with SystemUpdate. If we were using the Update method getting a Version Conflict issue.

Kamalasekaran avatar Feb 27 '25 12:02 Kamalasekaran

Hello @Kamalasekaran - Thanks for raising your query. We will look into it and let you know the updates.

ChetanSharma-msft avatar Mar 04 '25 05:03 ChetanSharma-msft

Hello @Kamalasekaran , I tried to repro the steps but while trying to register the application, can you help me with the Service Tree ID? Thanks!!!

Amey-MSFT avatar Mar 10 '25 11:03 Amey-MSFT

@Amey-MSFT Below Steps i followed to permit Sites.selected

Created Azure AD Enterprise Application with Sites.Selected Permissions

Image

After granting Admin Permissions Run the below Powershell to Select the Specific Sharepoint Site Site

Register-PnPEntraIDAppForInteractiveLogin -ApplicationName PnPApp -Tenant contoso.onmicrosoft.com -SharePointDelegatePermissions "AllSites.FullControl" -Interactive

Get the output of the AD Application ID and Connect to the SharePoint Site

Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/test -Interactive -ClientId efb5c1ff-3b30-4d56-aad7-073ed001ec05

And the Get the AD application ID and grant the permission Grant-PnPAzureADAppSitePermission -AppId 'be333d12-1978-4e29-8653-d6c6ca1992e0' -DisplayName 'Products (Development)' -Site 'https://contoso.sharepoint.com/sites/test' -Permissions FullControl

Kamalasekaran avatar Mar 10 '25 11:03 Kamalasekaran

Hello @Kamalasekaran , The permission you've mentioned, Sites.Selected, is used to grant access to specific SharePoint sites. However, in your PowerShell commands, you are assigning AllSites.FullControl permission, will the app might access sites that you don’t want it to?

Amey-MSFT avatar Mar 17 '25 04:03 Amey-MSFT

@Amey-MSFT Sorry for the Miscommunication First I registered the Pnpapp with Allsites.Fullcontrol as A Delegated Permission. Using this new PnPApp I was given Sites.Selected to our AD app with Application Permissions which is mentioned in Last Command.

Kamalasekaran avatar Mar 17 '25 05:03 Kamalasekaran

Thank you for the clarification! That makes sense now. So, the initial AllSites.FullControl permission was applied during the registration of the PnPApp as a delegated permission, and then Sites.Selected was granted to the AD app with application permissions to limit access to specific sites. Appreciate the explanation. Thanks!!

Amey-MSFT avatar Mar 18 '25 12:03 Amey-MSFT

Hello @Kamalasekaran , We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it. Thank you!

Amey-MSFT avatar Apr 03 '25 08:04 Amey-MSFT

@Amey-MSFT Any updates about this bug?

Kamalasekaran avatar May 13 '25 06:05 Kamalasekaran

Hello @Kamalasekaran, There are no updates from the engineering team on the issue at this moment.

Amey-MSFT avatar Jul 24 '25 05:07 Amey-MSFT

@Amey-MSFT, any update on this?

Kamalasekaran avatar Sep 25 '25 08:09 Kamalasekaran

@Amey-MSFT Any Update on this.

Kamalasekaran avatar Jan 13 '26 05:01 Kamalasekaran