SharePoint Updates from Word Online not accurate
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.
- Configure it with the Sites.Selected Application permission (SharePoint) and grant admin consent. Create an Azure Function:
- Develop an Azure Function (e.g., HTTP-triggered) to handle SharePoint Webhook notifications.
- 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).
- 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).
- Confirm the metadata update reflects in SharePoint. Observe Conflict:
- 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.
- 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.
Hello @Kamalasekaran - Thanks for raising your query. We will look into it and let you know the updates.
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 Below Steps i followed to permit Sites.selected
Created Azure AD Enterprise Application with Sites.Selected Permissions
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
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 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.
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!!
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 Any updates about this bug?
Hello @Kamalasekaran, There are no updates from the engineering team on the issue at this moment.
@Amey-MSFT, any update on this?
@Amey-MSFT Any Update on this.