I've set up a bot that calls two separate app script functions, but only one is successful in setting the returned value, using a data action in the next step. The first function creates a Google Drive folder if the [Folder URL] field is blank and the next function creates a spreadsheet from a template if the [Sample Data Sheet] field is blank. Both functions return a URL which I use the [Step Name].[Output] to set value of the fields in the next step (shown below).
Folder Creation:
Spreadsheet Creation
In the live app the Folder URL will not set the value even though the monitor logs show the URL has been returned, and in the copied app, the Sample Data Sheet URL won't set the value. For example, the automation monitor logs show the full URL successfully returned from the function in step 10, but in step 11, where I run the custom data action "Set Sample Data sheet URL" , the value is blank.
When these run separately in their own bot they work just fine which leads me to believe this is a bug. It seems that if you return two or more values from a script within a single process, at least one of your output variables (e.g. [Step Name].[Output]) will not work. In my live app the Folder URL output variable doesn't work and it's reversed in the copy of the app. Any help or guidance would be greatly appreciated.
Do a cell history from in your backend sheet. Does the empty value say that there WAS a value there and it was then replaced by "" ?
It does not, it says "" replaced with ""
Here's my experience with folder creation and so on...
When I first started doing this sort of thing I noticed that now and again, the folder id I was returning from my appscript was disappearing from the backend. Eventually I realised something was happening while the appscript was running.
What happened was that the user who had just spawned the record into being then continued to edit the record...this was while the appscript was taking a few seconds to run.
Now, at the time the record was spawned, the docid column was of course blank...it was appscripts job to fill that. Also, as the user was continuing to make edits to the record the sync engine knows that the docid column is still blank. So a race condition happens between user edits and the bot variable storage.
The only time I could guarantee that the appscript function return values were filled and not deleted again was to make any Action Buttons that caused edits to the row also NOT appear on the record if the docid column was still blank...this means the user HAS to wait for that column to be filled before any other edits to the row can be made.
I think I mentioned at the time that I didn't understand why Appsheet had to write values to columns that hadn't changed during a sync.
What I have said may not actually be the problem you are experiencing, but it's something to watch out for.
We actually ran into this exact problem during the development of this app where the edit history would show "some URL" replaced with "". We narrowed it down to the row being updated, using an action, by the user, while the process was still running. So the solution was to write it this way and put everything into one bot and now we've run into this bug return value bug.
On reflection...I reckon this is also related to https://www.googlecloudcommunity.com/gc/AppSheet-Q-A/Returned-Values-from-a-Process-Call-are-being-d...
This is an OUTSTANDING observation! Wow!
User | Count |
---|---|
16 | |
11 | |
5 | |
5 | |
5 |