How to change the "from" on a scheduled report?

tiguin2798
Tera Guru

Team, I am attempting to send out a scheduled report from a specific user with the display name being "Change Advisory Board". I saw the below script in another thread, but it is 7 years old so I'm not sure how it holds up as I am new to Java Script.

I planned to add this to my scheduled report.

${mail_script:u_setFromScheduled}


Therefore I created this new notification email script u_setFromScheduled with 'Script'

 

 

 

(function runMailScript(event) {


    email.setFrom(Travis Leach<abc@abc.com>');


})(current, template, email, email_action, event);
 
 
However, when I try to change the from 'Display Name' and enter the email address of the active user it should be sent as I receive this error. Any ideas on how to resolve?
tiguin2798_0-1712598086400.png

 

1 ACCEPTED SOLUTION

Astik Thombare
Tera Sage

Hi @tiguin2798 ,

 

Here's the breakdown of the issue:

  • Incorrect character: There's a non-breaking space character ( ) before Travis Leach. This character might not be interpreted correctly by ServiceNow.
  • Missing closing parenthesis: The closing parenthesis after the email address is missing.

Explanation:

  • The email.setFrom method takes a single string argument that specifies the sender's name and email address in the format "Name <email@address.com>".

Corrected Script -

 

 

(function runMailScript(event) {


    email.setFrom("Travis Leach<abc@abc.com>");


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

 

 

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

 

Thanks,

Astik

View solution in original post

4 REPLIES 4

Astik Thombare
Tera Sage

Hi @tiguin2798 ,

 

Here's the breakdown of the issue:

  • Incorrect character: There's a non-breaking space character ( ) before Travis Leach. This character might not be interpreted correctly by ServiceNow.
  • Missing closing parenthesis: The closing parenthesis after the email address is missing.

Explanation:

  • The email.setFrom method takes a single string argument that specifies the sender's name and email address in the format "Name <email@address.com>".

Corrected Script -

 

 

(function runMailScript(event) {


    email.setFrom("Travis Leach<abc@abc.com>");


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

 

 

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.

 

Thanks,

Astik

tiguin2798
Tera Guru

@Astik Thombare  Thank you so much!! I tested this and it worked perfectly. Thank you for the timely assistance.

Can I ask where you added "${mail_script:u_setFromScheduled}" into your scheduled report?

I seek the same results, but am at a loss as to where this would be placed.


Thanks in advance.