The CreatorCon Call for Content is officially open! Get started here.

How to trigger 1 notification that sends emails to 3 different email addresses, based on conditions?

ronro2
Tera Contributor

Hello Guys!

I'm trying to trigger one notification based on dmn_demand, that will be able to send 3 different emails depending on certain conditions. 

 

In the notification I have configured a "Send when: Revvord inserted or updated" 

ronro2_0-1725363836270.png

 

And then in an Email Script I have the following script: 

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
          /* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
          /* Optional GlideRecord */ event) {

    // Definiera e-postadressen baserat på sys_id
    var emailAddress;
    var companyConcerned = current.u_vgr_companies_concerned;

	//email1
    if (companyConcerned.indexOf('3d1fbtest') !== -1) {
        emailAddress = 'email1@example.se';

	//email2
    } else if (companyConcerned.indexOf('b51fbtest') !== -1) {
        emailAddress = 'email2@example.se';
	
	//email3
    } else if (companyConcerned.indexOf('a11fbtest') !== -1) {
        emailAddress = 'email3@example.se';
    }

    // Sätt mottagare
    email.setTo(emailAddress);

})(current, template, email, email_action, event);

 

However, no email is triggered when I try to test by changing state on a record based on table dmn_demand. I have referred to my Email Script name under "What it will contain" like this: 

${mail_script:email_script_behov_beredning_verksamhet}

Is there anything that I've missed? Do I need an event or a Business Rule? 


Thanks in advance!

5 REPLIES 5

LAXMI TODAKAR2
Tera Contributor

Hi @ronro2,

 

If you want to send mail notification to "To" email address, you can call event and pass the value to param parameter.

 

Thank You!!

Laxmi