@nico Awesome! ![]()
Wow… fantastic news @nico Many thanks ![]()
Hello,
I would like to know if the return of custom functions will also be implemented for use directly in the fields, as a function native to the platform?
No plan for this at the moment, though that would be cool. You can achieve a similar effect by making an Apps Script task that writes to particular fields in a table (using data action in the automation) and then you can use those fields in your regular app flow.
Good news, nested JSON support in Apps Script has been rolled out to all** users as of today! If you run into any issues, please let me know in a comment below.
The usage is the same as in the return value for webhooks. How to use:
- Setup your Apps Script function to return a nested object:
- Link the Apps Script project and name the key names with a dot “.” between them (e.g. “a.b” in this example).
- You can reference the return value in subsequent Automation steps as normal:
** A few users were excluded from the experiment if you had unsupported characters in the key name but you’ve been reached out to individually by email if this applies to you.
@nico , you are the best!! Thanks much!
Many thanks @nico I look forward to taking this new functionality for a spin. Great work and many thanks to you and your team.
You better to state this achievement in your following annoucement so that more people get aware of this new achievement.
@Koichi_Tsuji - Thank you! It will be included in today’s release notes (with a doc update)!
@nico , congrats for the wonderful work done by bringing script function.
I have doubt. Can you please tell me to get values and fed somewhere in the columns of a table if a script returns multiple values .
//Return values
URL 1 : api.hdiiekdndbd…
URL 2 : api.idodoelwle
Something like that. How to refer to the specific value for setting up values ?
In same way , if an api returns nested output. How to pull needed data from it. ?
Sample output by an api
Output:
[
{
“Validation Status”: “Valid Input”,
“Chargeable Weight”: “4500”,
“Base Tariff”: “300”,
“Service Tax”: “54”
}
]
@Koichi_Tsuji please help
Hi @jaichith
Thanks for the question and the sample output. Unfortunately a list of objects as a return object isn’t a supported format within for AppSheet’s Apps Script Task return values (see: Apps Script Return Type Docs). You will have to modify the returned object with array values in Apps Script before sending it to AppSheet. For example:
{
"Validation Status": ["Valid Input", ...],
"Chargeable Weight": ["4500", ...],
"Base Tariff": ["300", ...],
"Service Tax": ["54", ...]
}
(Notice the returned object values are arrays instead of singular values). And then you can access each key using the standard list functions.
As an addendum, here is some Javascript code to do the transformation from an array of objects to an object with array values if you’d like (for use in Apps Script):
// Any number of objects here
const arrayOfObjects = [
{
"Validation Status": "Valid Input",
"Chargeable Weight": "4500",
"Base Tariff": "300",
"Service Tax": "54"
},
];
function convertToObjectOfArrays(arrayOfObjects) {
return arrayOfObjects.reduce((acc, item) => {
for (const key in item) {
if (!(key in acc)) {
acc[key] = [];
}
acc[key].push(item[key]);
}
return acc;
}, {});
}
const returnValue = convertToObjectOfArrays(arrayOfObjects);
/*
returnValue will be:
{
"Validation Status":["Valid Input"],
"Chargeable Weight":["4500"],
"Base Tariff":["300"],
"Service Tax":["54"]
}
*/
(Notice the returned object values are arrays instead of singular values). And then you can access each key using the standard list functions.
Here you are asking me use functions like Index(list ,3) to fetch "base tariff " ?
Yes, to get individual values you can use the INDEX() function. So for example INDEX([ReturnValue].[Base Tariff], 1) to get the first base tariff.
Ok I will try and update you.
As you go through the process, keep an eye out at step 5 when the value is sent back from the outside system. In the meantime, the user waits for the sync to finish. If the sync doesn’t finish and the user tries to edit the same row but a different column, the returned value in the sheet gets replaced with an empty string, setting it back to its original value. This seems like a bug to me. Give it a try yourself and let us know how it goes. @Marc_Dillon
@nico this is a feedback that needs to be checked. Please have a look.
Last edit wins. As it’s always been, and probably as it always will be. This is a danger for any data changes that can occur in a bot while the record can be edited concurrently. Have butted heads with this multiple times, but have always managed to figure out a workaround.
I’m confused why there’s a delay (like 10-15 seconds) when syncing the bot, but other changes update much faster (1-2 seconds). Shouldn’t the wait period update the appsheet systems with new data too?
It would make sense if the appscript was being updated directly to the sheet, but I’m routing it back to the appsheet using return values. If this isn’t a bug, it seems kind of silly to me. @Marc_Dillon @nico
Maybe I’m misunderstand, but you’re adding extra steps with the app script execution, of course it would take longer, no?
Why would this happen? Not sure what you’re getting at there. Are you using wait steps in your bot or something? I certainly was not.
But it is in a sense “updating directly to the sheet”. The bot is working in its own app-state, which is a copy of the app-state from your client side when you first triggered the bot. Its data change is pushed to the data source first, and then your app is synced to pull that new data back in. But if you try to send another change into the sheet with a blank A value first, it’ll override the bot’s A value before it has a chance to read it in.



