Word API Field.updateResult() doesn't work when not executed from task pane add-in #4208
Labels
Area: Word
Issue related to Word add-ins
Needs: author feedback
Waiting for author (creator) of Issue to provide more info
Status: no recent activity
Issue or PR is stale (no recent activity)
Your Environment
Expected behavior
When calling updateResult() on a field it should update the field to the current custom property value. This should happen regardless from how the function is triggered.
Current behavior
Field.updateResult() gets executed but doesn't actually update the field values. It doesn't throw an error, but simply does nothing when triggered from an ExecuteFunction Action. When triggered from a Task Pane it works perfectly.
Steps to reproduce
Create an add-in with both a task pane action and an executeFunction action.
Create a Word document
Add a field to the document (Insert > Quick Parts > Field > DocProperty > {pick any prop that you will be able to update easily, I use Title for testing} )
Execute the following code snippet from both actions. (The task pane can be an empty web app, since the updateResult works when simply pasting the code in the dev tools console).
Context
We are building an add-in that gets properties from an API and stores these in the
document.properties.customProperties
. These custom properties are then inserted into a document as a docProperty field. We now have a Ribbon buttons that fetches the up-to-date properties from the API and sets them correctly in the custom properties. However when I iterate over the field collection and call the field.updateResult function, it simply skips over without error and continues.This behaviour is only when using an Action with type ExecuteFunction. If I run the exact same code from a task pane add-in it does work as expected.
Useful logs
I'd love to provide errors or logs, but I'm not getting any. Everything appears to execute successfully, but the field doesn't update.
The text was updated successfully, but these errors were encountered: