Office Add-in: Saving Custom Document Properties with Office js in Windows

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Office Add-in: Saving Custom Document Properties with Office js in Windows



I'm developing an add-in in macOS and I am able to read a custom document property:


return await this.api.run(async (context) => {
const properties = context.document.properties.customProperties;
properties.load('key,type,value');
await context.sync();

const roomID = properties.items.find(item => item.key === 'Webex_Teams_roomID');
return roomID ? roomID.value : null;
});



and write one:


return await this.api.run(async (context) => {
context.document.properties.customProperties.add('Webex_Teams_roomID', newRoomID);
await context.sync();
});



Where this.api is just window.word using office JS API. I used help from the following repo which is offered by Microsoft themselves, office-js-snippets.


office JS API



I'm not able to run my code in window's machine. After debugging the code, I learned that my code gets stuck at this point: await context.sync();.


await context.sync();



Office Versions in macOS: 16.14.1 (180613).


16.14.1 (180613)



Office Version in Windows: 16.0.4639.1000 32-bit


16.0.4639.1000 32-bit



After some digging, I found that I don't have access to context.document.properties.customProperties.items. It will display <permission denied> error. Could this be it?


context.document.properties.customProperties.items


<permission denied>



And I set the Permissions to ReadWriteDocument:
<Permissions>ReadWriteDocument</Permissions>
Nothing....


Permissions


ReadWriteDocument


<Permissions>ReadWriteDocument</Permissions>




2 Answers
2



My best guess is that this has to do something with how async/await (not)works on IE11 and that you will have to add correct polyfill to handle this.





that's a very good point. Let me check it out. Please look at my updated post as well.
– Arash Koushkebaghi
yesterday





As It turned out, Async/Await works fine on IE 11. As I tested my code separately on IE 11. So I think the problem is reading document properties. For some reasons Office API is not allowing to read the items property from context.document.properties.customProperties.
– Arash Koushkebaghi
21 hours ago


Async/Await


items


context.document.properties.customProperties





If everything works after updating permissions great but I still think it is a bug because I would expect same behaviour on Mac and Windows versions of Office with the same set of permissions. If you have read permissions you should only read properties and get permissions denied on write. If you are certain that this is the case and you can spare 10 mins please go and open a ticket at github.com/OfficeDev/office-js/issues you might help someone else facing the same issue.
– Dalibor Grudenic
16 hours ago





Issue created here
– Arash Koushkebaghi
2 hours ago



It turned out with this MSI build and the API that I'm using, there are some incompatibility issues that result into causing the problems that I had ealier. they suggest I move to 365.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP