Changing the SNOW Email notification "From" or Reply TO depending on Departments.

EricG
Kilo Sage

I have a need, depending on WHO is working a ticket, to change the From and Reply To USER to the appropriate email.

 

Use Case:

If the Finance group is working the ticket, then the From / Replay should show "Finance Department <finance@company.com>".

Or our Security Group, then "Security <security@company.com>", etc...

 

I've attempted to use the OOB From and Reply To fields, as well as, adding a mail script:

if(current.assignment_group =="guid_id"{
     email.sentFrom("My Group <group_queue@company.com>");
}
else if(current.assignment_group =="guid_id2"{
     email.sentFrom("My Group <group_queue2@company.com>");
}
etc....

 

Either way i sent this, the system show the Notification in the SENT mailbox, however, I never receive the email.  If i remove this, then it sends.

 

Should I contact HI or is there a property/BR/SOMETHING that is not allowing the email to go out.

 

THanks.

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@EricG Update your code as follows.

 

if(current.assignment_group =="guid_id"{
     email.setFrom("My Group <group_queue@company.com>");
}
else if(current.assignment_group =="guid_id2"{
     email.setFrom("My Group <group_queue2@company.com>");
}

 

There is no method with name sentFrom exist on the email object hence the script is crashing. Instead the method name is 

  • setFrom(String address): override the sender address.

For more information please refer to https://docs.servicenow.com/bundle/tokyo-servicenow-platform/page/script/server-scripting/reference/...

 

Hope this helps.

OOPS. 😁  LOL.  It's hard being dyslexic too.

Sandeep Rajput Ok - the email is going out (being sent to my TEST mailbox) however it's still showing IT Help Desk

EricG_0-1700497803082.png

It should have been option 1 group_queue@company.

Do i need to remove the Email Account system property?

EricG_1-1700497925903.png

 

@EricG Could please check if the from field is populated on the notification if yes then please remove it and only set it via the mail script.

 

Source: https://www.servicenow.com/community/now-platform-forum/how-to-set-the-email-user-label-from-script/....