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.

Where to provide email.setFrom() when using scripted scheduled job?

Rajini2
Mega Sage

I have a scripted schedule job where reports are sent to users dynamically. Now I need to set "From" in those emails.

 

Where do I provide that?

1 ACCEPTED SOLUTION

Rajini2
Mega Sage

OK I figured that myself.

 

1. Created a email script "FromMajorIncident"

 

 

email.setFrom("Major Incident Management <MajorIncidentManagement@test.com>");

 

 

2. Included that email script in my scheduled job script as

 

 

var scheduled_report = new GlideRecord('sysauto_report');
scheduled_report.report_body = "bla bla bla<br/>${mail_script:FromMajorIncident}";

var answer = scheduled_report.insert();

 

 

 

It worked.

View solution in original post

1 REPLY 1

Rajini2
Mega Sage

OK I figured that myself.

 

1. Created a email script "FromMajorIncident"

 

 

email.setFrom("Major Incident Management <MajorIncidentManagement@test.com>");

 

 

2. Included that email script in my scheduled job script as

 

 

var scheduled_report = new GlideRecord('sysauto_report');
scheduled_report.report_body = "bla bla bla<br/>${mail_script:FromMajorIncident}";

var answer = scheduled_report.insert();

 

 

 

It worked.