Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to call email script in subject?

Kiddy1
Tera Contributor

i have created an email script name es

 

i called it in subject and body

 

subject : ${email_script : es} --not working

 

body: ${email_script: es}  -- working

1 ACCEPTED SOLUTION

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

I think it will be a domain seperated instance . Please use it as below

See below code:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
       
        // Add your code here
        var priority_value=current.getValue('priority');
if(priority_value == 101)
        {
                value='1';
        }else if(priority_value==102)
        {
                value='2';
        }
else if (priority_value==103)
        {
                value='3';
        }
else if (priority_value==104)
        {
                value='4';
        }

template.print(value);

gs.log('priority value is' +priority_value,'lghori103');
       
        email.setSubject(current.sys_domain.name +"-"+current.service_offering.getDisplayValue()+": Incident "+current.number+"- P"+value +" is assigned to your group");

       
 Thanks,

Ashutosh Munot

 

View solution in original post

3 REPLIES 3

can you tell me from above script name the syntax to call it in subject?

Ashutosh Munot1
Kilo Patron
Kilo Patron

Hi,

I think it will be a domain seperated instance . Please use it as below

See below code:

(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
       
        // Add your code here
        var priority_value=current.getValue('priority');
if(priority_value == 101)
        {
                value='1';
        }else if(priority_value==102)
        {
                value='2';
        }
else if (priority_value==103)
        {
                value='3';
        }
else if (priority_value==104)
        {
                value='4';
        }

template.print(value);

gs.log('priority value is' +priority_value,'lghori103');
       
        email.setSubject(current.sys_domain.name +"-"+current.service_offering.getDisplayValue()+": Incident "+current.number+"- P"+value +" is assigned to your group");

       
 Thanks,

Ashutosh Munot