问题
I'm trying to send a email using form and also save the history of all the email. and I have a field in database named success to track if the email has send or not. How to update values of a field from client script based on user activities or email sent status.
var success = app.models.ChangeSystem.fields.Success.possibleValues;
google.script.run
.withFailureHandler(function(error){
status.text = error.message;
success = False;
})
.withSuccessHandler(function(result){
status.text = 'Email sent';
success = True;
clearEmailForm();
})
.sendEmailMessage(to, subject, msg);
Here success is a field in my database. My script is sending email. and update the I was expecting to update the value of success which has two possible values(I'm fine if I have to change the field to boolean). Anyone can give me a direction how to achieve that?? Thanks in Advance.
回答1:
Typically if you are creating a record that has a dependency on an email being sent then you need to implement the email function and call back inside the success function of the record being created like so:
Lets say you have a form with a button that creates a record that has an email sent status field then your 'Submit Button' should have the following code:
var status = app.pages.Email.descendants.EmailStatus;
widget.datasource.createItem({
success: function(result) {
google.script.run
.withFailureHandler(function(e) {
status.text = e.message;
result.Success = false;
})
.withSuccessHandler(function() {
status.text = 'Email sent';
result.Success = true;
})
.sendEmailMessage(to, subject, msg);
},
failure: function(error) {
status.text = error.message;
}
});
来源:https://stackoverflow.com/questions/57061468/im-trying-to-update-value-of-a-field-from-client-script