Hi,
Problem:
With the App Script Pack, i invoke a Google App Script. I want to parse the returned JSON on the fly, without writing the result to a result column in my table. Is that possible?
I can’t really share my doc, since i don’t think it’s secured enough (too much write rights on my gdrive, sorry).
Context:
I have created a Google App Script with some functions that perform Google Drive actions (e.g. create a folder and return the id).
I have a table called “Projects” with some columns, one of which is the Foldername and ReturnCreateFolder.
Button code:
ModifyRows(
thisRow,
Projects.ReturnCreateFolder,
[Apps Script]::TriggerWebApp(
“https://script.google.com/macros/s/AKfycbyjSXaIvaAEcWfqLp_mcjprzGmQnDORtifxbd7h1LgWbb97thsij6-jdy4hg07_CH33vQ/exec”,
method: “POST”,
body:
[Apps Script]::JSONBody(
“action”,
“createFolder”,
“folderName”,
thisRow.Foldername,
“parentFolderId”,
thisRow.ProjectsParentFolderID
)
)
)
This button returns the following result into the column “ReturnCreateFolder”
{“success”:true,“message”:“Map ‘Bewind Antonio Nzola’ succesvol aangemaakt.”,“folderId”:“1RzAULj_7ohnhWh0rsy462YlYHEe1”}.
I can write a formula to parse this result (e.g. ParseJSON(thisRow.ReturnCreateFolder,“$.folderId”) that parses this result into a new column… but is there a way to do it all in one?
So… inside my button, parse the result immediately?
I tried this code:
let([Apps Script]::TriggerWebApp(“https://script.google.com/macros/s/AKfycbyjSXaIvaAEcWfqLp_mcjprzGmQnDORtifxbd7h1LgWbb97thsij6-jdy4hg07_CH33vQ/exec”,
method: “POST”,
body:
[Apps Script]::JSONBody(
“action”,
“createFolder”,
“folderName”,
thisRow.Foldername,
“parentFolderId”,
thisRow.ProjectsParentFolderID
)),n,ModifyRows(thisRow,thisRow.ProjectFolderID,ParseJSON(n,“$.folderId”)))
but it won’t worK… throws a “Unexpected token ‘e’, “external” is not valid JSON”