Notification email script on who will receive condition

Trupti Krishnam
Tera Contributor

Can anyone give an example to how to write an email script to 'who will receive' condition which can not be achieved through simple way for 

1. Trigger ID.Business Analyst.Manager and Trigger ID.Developer.Manager and Trigger ID.Agile Team.Manager.

It should be sent to this people when ever the notification is conditions are met 

2.This conditions are from the Assessment Instance Table

Thanks ! 

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

Hi @Trupti Krishnam ,
I trust you are doing great.
Please find below code for the same

// Check if the current notification is triggered by a record in the Assessment Instance Table
if (current.table == 'x_assessment_instance') {

  // Define the conditions that need to be met
  var conditionsMet = false;

  // Check if the conditions are met for Business Analyst Manager
  if (current.trigger_id == 'ID.Business Analyst.Manager' && /* additional conditions */) {
    conditionsMet = true;
  }

  // Check if the conditions are met for Developer Manager
  if (current.trigger_id == 'ID.Developer.Manager' && /* additional conditions */) {
    conditionsMet = true;
  }

  // Check if the conditions are met for Agile Team Manager
  if (current.trigger_id == 'ID.Agile Team.Manager' && /* additional conditions */) {
    conditionsMet = true;
  }

  // If any of the conditions are met, send the email
  if (conditionsMet) {
    var email = new GlideEmailOutbound();
    email.setSubject("Notification Subject");
    email.setBody("Notification Body");
    email.addRecipient(current.manager_email); // Use the appropriate field for manager's email
    email.send();
  }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi