'getDocumentProperties() not working anymore when migrating Editor Add-on to Google Workspace Add-on

I'm converting my script from an Editor Add-on (bound to a sheet) to a Google Workspace Add-on (using the Cards). However, after converting, I noticed that the PropertiesService.getDocumentProperties(); started to return null. I'm using this to store specific information bound to this document and I do not want to store this info under userProperties or scriptProperties (for storage quota, @domain.com access, and other reasons)

The documentation mentions:

It is only available if the script is published and executing as an add-on or if it is bound to a Google file type.

Does it mean it will work for Google Workspace Add-on, only after publishing on the marketplace in a domain or publicly?

How do I test my Workspace Add-on then? I installed the unpublished add-on for testing:

  1. Deploy --> Test deployments
  2. Test latest code --> Install
  3. Click Done

however, as stated above, I cannot test the functionality using getDocumentProperties.

As a bypass, I'm now using the 'userProperties' to simulate the behavior, however I will convert back to 'documentProporties' just before publishing. It feels strange to test code --> change code --> publish to the world...

Can someone share experience on this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source