Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 12:15 PM
Business rule -
(function executeRule(current, previous /*null when async*/ ) {
var fields = current.getFields();
for (var i = 0; i < fields.size(); i++) {
var field = fields.get(i);
if (field.changes()) {
var name = field.getName();
var fieldLabel = field.getLabel(); // Get the field's label
var prev = previous.getDisplayValue(name); // Get the previous value of the field
var value = field.getElementValue(name); // Returns the unformatted value of the element
var disValue = field.getDisplayValue();
gs.addInfoMessage('Field Name: ' + fieldLabel +
' | Previous Value: ' + prev +
' | Current Value: ' + disValue);
gs.eventQueue("field.changes", current, prev, disValue);
}
}
})(current, previous);
Notifications -
Notification Email script -
(function runMailScript(current, template, email, email_action, event) {
// Add your code here
var fields = current.getFields();
var fieldLabel = ""; // Initialize fieldLabel variable
for (var i = 0; i < fields.size(); i++) {
var field = fields.get(i);
if (field.changes()) {
fieldLabel = field.getLabel(); // Get the field's label
break; // Exit loop after finding the changed field
}
}
var emailBody = "Hello,\n\n" +
"This is to inform you that the value of the field " + fieldLabel + " has changed.\n\n" +
"Previous Value: " + event.parm1 + "\n" +
"New Value: " + event.parm2 + "\n\n" +
"Please review the changes at your earliest convenience.\n\n" +
"Best regards,\n" +
"[Your Company Name]";
template.print(emailBody);
})(current, template, email, email_action, event);
Name - field_value_changed
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 12:57 PM
Hello @Prithvi Ramesh1 ,
The correct syntax for including your Email Script would be:
${mail_script:field_value_changed}
Regards,
Robert
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 12:16 PM
When the notification is triggered, then the body returns as empty.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2025 12:57 PM
Hello @Prithvi Ramesh1 ,
The correct syntax for including your Email Script would be:
${mail_script:field_value_changed}
Regards,
Robert