Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to set incident Caller as sender (FROM) in notification

JugantaN3978112
Tera Guru

Hi,

I have a requirement  to set incident Caller as sender (FROM) in notification. One script i have written but it seems it's not working.

 

Script:

(function(){
    var callerEmail = current.caller_id.email;
    if(callerEmail){
        email.setFrom(callerEmail);
    }
    else{
        email.setFrom('no-reply@example.com');
    }
   
})();
jugantanayak_0-1716209372515.png

 

2 REPLIES 2

Gangadhar Ravi
Giga Sage

this should work.

 

if (email.origemail == '[email_address]') {
        var arrSubject = email.subject.split(' : '); //need to include the 
        var gr = new GlideRecord('sys_user');
        gr.addQuery('user_name', arrSubject[1]);
        gr.query();
        if (gr.next()) {
            current.caller_id = gr.sys_id
        }
    } else {
        current.caller_id = gs.getUserID();
    }

Please mark my answer correct and helpful if this works for you.

 

Not applicable

Hi @JugantaN3978112 ,

 

Are you trying to send notification on behalf of caller? If yes please follow the below link 

 

https://www.servicenow.com/community/developer-forum/email-different-quot-from-quot-address-display-...

 

I started answering community questions recently. Please mark my answer as helpful if it helps you in any way.