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.

Is it possible to use notification script in subject line?

Julian Reis
Tera Contributor

Hi everyone,

 

i would like to know, if it is possible to use notification script in notification subject line. My notification script in "sys_script_email" table is called "Get Project Name" and i have already used it in my Message HTML part -> "Project ${mail_script:Get Project Number} is created.". My Problem is, that i also want to use this mail script in my subject line. Is this possible?

 

 Any guidance on how to achieve this would be greatly appreciated!

1 ACCEPTED SOLUTION

shibasou
Kilo Sage

Hi.

 

Try incorporating the following script into your "Get Project Number" script.

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
        var subject;
        var message;
~~
        subject = "your subject name";
        message = "your text";
~~
        template.print(message);
        email.subject = subject;
    }
})(current, template, email, email_action, event);

 

Mark Helpful if you accept the solution.

Thank you.

View solution in original post

1 REPLY 1

shibasou
Kilo Sage

Hi.

 

Try incorporating the following script into your "Get Project Number" script.

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {
        var subject;
        var message;
~~
        subject = "your subject name";
        message = "your text";
~~
        template.print(message);
        email.subject = subject;
    }
})(current, template, email, email_action, event);

 

Mark Helpful if you accept the solution.

Thank you.