Hi All, I am trying to recall a data item in the App Script. Here is what I have:
var timeZone = Session.getScriptTimeZone();
var Data = {
Id: Id
}
const payload = JSON.stringify({ text: "Site Manager - DMS Services - Please Re-Synchronise - TEST POST - "+ Data + " "+Utilities.formatDate(new Date(), timeZone, “dd-MM-yyyy | HH:mm:ss”)});
What do I need to set in the Data variable to read the parameter [Id]?
1 Like
In your script, you access the value that was passed into the parameter through the parameter argument:
- In your example: Parameter1
So your code to build the data object would be:
var Data = {
Id: Parameter1
}
Here’s a link to the first of a series of apps that shows how to create an app that integrates generative Ai: https://www.appsheet.com//templates/ChatGPT-in-AppSheet?appGuidString=07b05f62-3865-4e9a-823c-a086408c4362
Inside there you can see:
- How the app is configured to call the script
- How the script is configured to accept the values from AppSheet
- How the script returns values (in case you need to do that too)
- How AppSheet accepts values back
NOTE: this app is built around an older OpenAi model that’s no longer in use. But that’s not the point; the point is to demonstrate how to use scripts. 
I did actually manage to resolve the issue. To recall the data this is what is required:
function sendMessage(ID,DATEI){
The data needs to be called within the function call. Then the data can be fed into the const:
const payload = JSON.stringify({ text: "Site Manager - DMS Services - Please Re-Synchronise - "+ (ID) + " - “+(DATEI)+”