How to use applyAsync() in javascript

I am using javascript code to fetch items of some itemType, I see two method in aras - apply() and applyAsync().

How do i use applyAsync()? An example of working code would be helpful.



  • Hi Vinay,

    the method "cui_common_favoritesearch_init" (it was included in my standard Innovator 12.0 installation) contains some code using applyAsync():

       .catch(function() {
           return function(dataItem) {
               dataItem.roots = [];
      = new Map();
               dataItem.disabled = true;
               return dataItem;



  • Hi Vinay,

    I answered another forum post with a use case for applyAsync() that I wanted to share here. The users there were trying to display a spinner to let the users know that a long item query was running. The code in the Gist below uses applyAsync() to satisfy this use case by starting the spinner, doing an apply with applyAsync(), and then stopping the spinner after it returns.

    The difference between apply() and applyAsync() is that apply() halts the execution of your code until the query is completed at which point it will return an item containing the results of your query. applyAsync() on the other hand returns a Promise that can eventually handle the result of the query and does not halt your code. There's a number of different articles available online (like this one) that explain Promises, asynchronous code, and the benefits of using them.


    Christopher Gillis

    Aras Labs Software Engineer