I am facing a challenge in Google App Maker where I am attempting to execute a Client Script to retrieve a variable and then pass that variable to a Server Script for further use. However, I am struggling to figure out the correct implementation.
Within my Client Script, I am looking up information in a table named OrderItems
and retrieving the ProductNumber
from the current record.
Subsequently, the Client Script triggers the Server Script which is expected to utilize the ProductNumber
received from the Client Script to perform a query on another table.
CLIENT SCRIPT
var productNumberToUpdate = app.datasources.Purchase_Order_Line_Items.item.Stocked_Item_Product_Number.toString();
google.script.run.serverScript();
SERVER SCRIPT
var query = app.models.Inventory_Item.newQuery();
query.filters.Part_Number._startsWith = productNumberToUpdate;
var results = query.run();
var id = results[0]._key;
The Client Script executes successfully, however, the Server Script throws an error ReferenceError: productNumberToUpdate
is not defined. It is evident that the variable productNumberToUpdate
has not been declared, hence the need to pass it from the Client Script.