Hello,
I am trying to add a new row to an Appsheet table using Appscript, but the row includes table references. How do I include this in the rows value? The following does not work:
const rows = [
{
“Title”:“123”,
“User”:‘<<FILTER(“Users”, [Title] = “test”)>>’,
“Date”: “12/07/2023”,
“Shift”: ‘<<FILTER(“ShiftTemplate”, [Title] = “A Test”)>>’
}
];
I don’t think Apps script understands the ‘<<’ and ‘>>’ syntax? I just want to be able to enter a Ref type as a value. Is this supported?
1 Like
Apps Script has no knowledge of AppSheet syntax.
You have to retrieve key values directly from the appropriate sheet of the spreadsheet within Apps Script, which should not be difficult, and use those values to construct the rows list to be submitted to AppSheet API.
Thanks for clarifying about the Appsheet syntax, however I’m not sure what you mean. Can you provide what the syntax might look like on an Appsheet API submission? Suppose my row number is 1 from the table ‘Users’, what would I enter as the value for ‘User’, to make it a valid entry in the Appsheet DB?
Should be just
“User”:“a1b1c.”
Simply a text value. No expression.
I get an error because the expected type of “User” is Ref, not a text. By the way I am not using google sheets, but the appsheet database only.
Ref type just means it points to a key of another table. The key is usually a text and a text value works just fine. See a sample execution of an Add action. order_id and item_id are of ref type. I just used text strings as their value.
As for getting key values of Users, since you are using AppScript DB, you cannot get them using Apps Script as you are aware. Since you are able to specify the user name, then you somehow need to get the corresponding key value…
1 Like