Update your custom functions project

Office Add-ins team

Update an old project 

If you built your custom functions project using the Yo Office Yeoman generator template during the preview period prior to 6 May 2019, you’ll want to update parts of the project ensure it is using the GA version libraries and features.  

To convert a project:  

Update the CDN location 

The post-GA Yo Office template included a change to the script file that governs the custom functions’ runtime and moved from a temporary GitHub location to a permanent CDN on https://appsforoffice.microsoft.com/. 

In the HTML file for your add-in, delete the script reference which is used to load custom-function-runtime.js. Because the preview Yo Office template changed frequently, this might refer to a temporary GitHub location like the following code snippet, but you may see a different location depending on your project.  

<script src="https://officedev.github.io/custom-functions/lib/custom-functions-runtime.js" type="text/javascript"></script>

 And replace it with this script reference instead, which includes the updated CDN location:  

<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/custom-functions-runtime.js" type="text/javascript"></script>

To learn more about this runtime, see our docs on the custom functions architecture. 

Change any mentions of  ‘AsyncStorage‘ to ‘storage’ 

The AsyncStorage object was rewritten with different methods and a new name. You’ll want to make sure all mentions of AsyncStorage use the new object, storage. Method changes are listed in the following table, although you can also use the built-in IntelliSense in Visual Studio Code to look for correct methods.   

The following table lists the methods that are changed:

Old method  New replacement 
multiGet  getItems 
Multiset  setItems 
multiRemove  removeItems 
getAllKeys  getKeys 

 

Deprecated methods:  

  • flushgetRequests 

Methods that have not changed between templates:  

  • GetItem 
  • setItem 
  •  removeItem  

As a reminder, storage is limited to 10 MB of data per domain (which may be shared by multiple add-ins). For more information about storage, see Save and share state in custom functions. 

Happy developing! 

Michelle Scharlock

Office Add-ins Developer Education Team

Feedback usabilla icon