Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I suppose, the error cause is that the Cache <code>get</code> method returns null during the 1st execution when the cache is empty. The <code>Utilities.jsonParse</code> throws an exception and the cache becomes in any case empty. Try to use the following modified code.</p> <pre><code>function _responseToNext(e) { var app = UiApp.getActiveApplication(); app.getElementById('btnPrev').setEnabled(true); var cachedCurrent = CacheService.getPublicCache().get('currentItem'); var current; if (cachedCurrent == null) { current = 0; } else { current = parseInt(cachedCurrent); } var cachedAgendaItems = CacheService.getPublicCache().get('agenda'); var agendaItems; if (cachedAgendaItems == null) { agendaItems = [][]; } else { agendaItems = Utilities.jsonParse(); } agendaItems[current]['notes'] = e.parameter.tAreaNotes; agendaItems[current]['status'] = e.parameter.lboxStatus; CacheService.getPublicCache().put('agenda', Utilities.jsonStringify(agendaItems)); current = current + 1; CacheService.getPublicCache().put('currentItem', current); fillAgendaDetail(app); // only enabled 'Next' if there are more items in the agenda if (current &lt; agendaItems.length-1) { app.getElementById('btnNext').setEnabled(true); } return app; } </code></pre> <p>Also please mention that the Public Cache (<code>CacheService.getPublicCache()</code>) is the same for all users of your script. In your case, this means, if two users <code>user1@example.com</code> and <code>user2@example.com</code> use the script they will have the same <code>current</code> and <code>agendaItems</code> variables values, i.e. it can be a situation when the <code>_responseToNext</code> handler is already executed under the <code>user1</code> authority - the <code>current</code> variable is equal to 1, after the user2 executes the <code>_responseToNext</code> handler - the <code>current</code> variable is equal to 2 and so on. If you do not need such behaviour, use the <code>CacheService.getPrivateCache()</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload