Below is the code for the custom button. The objective is to store different gender and rating for different button:
var gender='Ladies';
var rating='Good';
setRating(gender, rating);
The method implementation for setRating(gender, rating) is wrote on the client script as follow. The objective is to tell browser javascript to activate sendRating(gender, rating) function.
function setRating(gender, rating){
google.script.run
.withFailureHandler(function(error) {
// An error occurred, so display an error message.
status.text = error.message;
})
.withSuccessHandler(function(result) {
// Report that the email was sent.
status.text = 'Thank you for the feedback';
})
.sendRating(gender, rating);
}
Below is the sendRating(gender, rating) implementation wrote on the server script. The objective is to tell AppMaker javascript to activate .saveRecords API to save the gender and rating records to the datasource called ToiletRating. The datasource contain field such as 'Gender' and 'Rating'.
function sendRating(gender, rating){
var db = app.models.ToiletaRating.newRecord();
person.Gender = gender;
person.Rating = rating;
app.saveRecord([db]);
}
Can you help me why I get this error saying that newRecord method is undefined while I have declare it in the Server script line no. 3 .
E
Wed Feb 28 09:47:42 GMT+800 2018
TypeError: Cannot call method "newRecord" of undefined. at sendRating (NewScript:3)
ToiletaRating? - Morfinismo