Hi Levent,
Thanks for your prompt response!
While it did answer my question to a point, it has raised some more!
Before I get into the details, please know that I’m VERY new to all this-about a month: Google Sheets, AppSheet or any kind of coding!
So, I followed your suggestion and published my Script as WebApp and used its URL as a Webhook in the Workflow of the ApSheet. So far, so good
But it doesn’t work!
Upon testing, I got the following error message:
Failed: Action not performed because 1 errors are present. Error: Failed to parse JSON due to Unexpected character encountered while parsing value: h. Path ‘’, line 0, position 0…
My Script is very simple:
function addRecord() {
var ss=SpreadsheetApp.getActive();
var sh1=ss.getSheetByName(‘Random’);
var sh2=ss.getSheetByName(‘Add’);
var Range=sh1.getRange(“D2:D2”).getValues();
sh2.appendRow(Range[0]);
}
It simply adds a new record, in a new Table’s appended row, from a list of random names from another Table. I’ve assigned this Script to a button on the Google Sheet, and it works perfectly, as expected, if I’m clicking the button from the Sheet. It does not have, nor does it need any other triggers such as onOpen, onChange, etc. It is a manual “click” on the button, and needs to remain a manual click.
Now on the AppSheet app that I’ve created, the app pulls the name (and the associated information such as images, etc.) from the newly appended row in Google Sheet and presents it like a slideshow to the user of the app, in a completely random manner. However, if the user of the app is able to click/touch a button on the APP, which in turn triggers the Script on the Google Sheet, then they would not need to have access to the Sheet! I need that to keep the sheet safe! As a workaround, I’ve placed an Action button on the App, which forwards one “slide” at a time upon clicking the App button in a Detail View. (But for this I need to manually “advance” all the slides on the Sheet (which the user is not aware of), but then it is not truly dynamic or random, for that matter! And I always need to stay involved!!
After I got the above error, I researched the publishing of the WebApp. There seem to be two requirements for that:
"A script can be published as a web app if it meets these requirements:
As you can see, I don’t have either doGet(e) or doPost(e) in my Script, and I don’t even know what the “objects” are in the second requirement!
So these questions:
- How was I able to actually publish my Script on the web (and get it’s URL) when I have neither doGet nor doPost?
- What is causing the error message above? How do I fix that?
- What you are suggesting is Behavior > Workflow > Webhook to connect the App and the Script on the Sheet. However, the App Action buttons are created from Behavior > Actions > Action Icon > Prominence. So how do I assign a Button to a Webhook?
- Since the whole idea of the AppSheet is a No-Code environment, and since AppSheet seems to work like a “wrapper” around a very specific “container”, in my case a Google Sheet, why can’t a specific “tunnel” be possible to trigger the specific Script on that specific Sheet from that specific App (without having to “go outside” and do the webapp publishing, linking the URL, establishing the Workflow webhook, etc.? The specific one-to-one relationship between the Sheet and the App already exists, so why complicate the matter by having to “go outside”? (The “Tunnel” would be something like, in a Sheet when you design and save a Button, place it on the Sheet, and then simply “Assign a Script” to that Button! It just works! That simple!!) Something to think about!
I’ve also CCd Praveen so that you folks can think of how to make this whole experience truly no-code, to encourage people like me!
Many thanks again!
Warm regards,
Parag Raval