Reputation:
I have a table naming Employee in Appmaker. Lets say it contains 3 records.
empId empName empAge
1 Abc 29
2 Def 26
3 Xyz 30
I have 2 forms :-
AddEmployee - It has datasource Employee(create) to create new Employee
EditEmployee - It has datasource Employee to edit Employee records.
I have set the onClick function of the Employee table row to open the record in the EditEmployee form and it works fine. (POST method is used by default)
However I want to use GET method. Requirement is to send the URL of a particular record in email to someone such that when the person clicks on the URL that record opens up in the EditEmployee form.
I tried the below expecting the 2nd record to open but it always opens the tables's first record in the form irrespective of the requestId value.
app.datasources.AppSettings.item.AppUrl+'?requestId=2#EditEmployee';
Any suggestions please?
Upvotes: 1
Views: 197
Reputation: 5253
I recommend you to use google.script.url api. The best thing to do is to include some script in the onDataLoad event of the table. Take the following for example:
google.script.url.getLocation(function(location){
var rId = location.parameter.requestId;
var hash = location.hash;
if(rId && hash === "EditEmployee"){
var ds = app.datasources.Employee;
ds.selectKey(rId);
}
});
The above assumes that the hash #EditEmployee refers to a page named EditEmployee, because if it is a page fragment, the approach changes a bit. Nevertheless, this should give you an idea. Of course, your question is missing required info to help me give you a complete answer so this is the best I can do now.
Upvotes: 2