I'm setting up a google-app-maker app. I want to sort a table with a query.
I want to call a script onAttach-Event. Because I need to user the "query" to sort my data, I have to use a server script. In google-app-maker i can't use a query at client script, right?!
But every time I try to call the server script I get an error
SEVERE: Failed due to circular reference
onAttach Event:
google.script.run.withSuccessHandler(function () {
}).sortTable(widget);
The server script:
function sortTable(widget) {
}
I have already a worked server script. This works perfect. I call this from "App startup script" like:
google.script.run.withSuccessHandler(function(reValue) {
...
}).initUserData(startCode);
Server script here:
function initUserData(startCode) {
...
}
The query looks like:
function sortTable(widget) {
var people = widget.parent.datasource.relations.People;
var query = people.newQuery();
query.sorting.PeopleRole._descending();
// query.sorting.Name._descending(); // sorted by people.Name
var records = query.run();
app.saveRecords([records]);
...
}

people.newQuery()that is where your circular reference comes in because your server script can't interpret the datasource being passed from your widget. If you let us know what you are trying to accomplish maybe we can help. Also, why are you calling a sort table in the app start up vs just from either the client or within the datasource server script? - Markus Malessa