Updating form field from notification email script

nikcr
Tera Contributor

Can we update the current form field from the notification email script, I have a requirement to clear the value of a form field once the notification scripts are executed. 

1 ACCEPTED SOLUTION

Hello,

I'm not sure what you mean by "current form field"? Unless you mean a field on the "current" record that the notification is all about? If so, then yes, you can. You mentioned after the notification scripts execute, then notification scripts execute as the email is being sent...so...that is why I suggested you to do it after.

 

If you're referring to doing it as part of the form, then you can do it in an email script such as:

var rec = new GlideRecord('table_name');
rec.addQuery('sys_id',current.sys_id.toString());
rec.query();
if (rec.next()) {
rec.setValue('field_name', 'value');
rec.update();
}

So you'd just replace the table_name with the table involved here, field_name with the appropriate field name on this record, and the value as needed in a mail script and this will update a field on the current record.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

7 REPLIES 7

Allen Andreas
Administrator
Administrator

Hello,

If this needs to happen 'after' the email has been sent, then you'd have to look into something like an 'after' business rule on the sys_email table to then run a GlideRecord query to that record and then clear the field(s) value.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thanks Allen! But I would like to whether is it possible to update the current form field from the notification email script. 

Hello,

I'm not sure what you mean by "current form field"? Unless you mean a field on the "current" record that the notification is all about? If so, then yes, you can. You mentioned after the notification scripts execute, then notification scripts execute as the email is being sent...so...that is why I suggested you to do it after.

 

If you're referring to doing it as part of the form, then you can do it in an email script such as:

var rec = new GlideRecord('table_name');
rec.addQuery('sys_id',current.sys_id.toString());
rec.query();
if (rec.next()) {
rec.setValue('field_name', 'value');
rec.update();
}

So you'd just replace the table_name with the table involved here, field_name with the appropriate field name on this record, and the value as needed in a mail script and this will update a field on the current record.


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi @nikcr 

Thanks for marking my reply as Helpful.

If my reply also helped guide you Correctly, please also mark it as "Accept Solution"

Thanks and take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!