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

want to populate from to fields as logged user email id

Aarushi1991
Tera Contributor

Folks,

 

i am a having a Quick message where i am trying to populate from text as : logged user email id

 

Aarushi1991_0-1743145498939.png

 

 

email script :

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {

    // Add your code here


    var user= gs.getUserID();
    var usertable= new GlideRecord("sys_user");
    usertable.get(user);
    usertable.query();
    if(usertable.next()){
        var emailid=usertable.email;
    }
    gs.info("Email id"+emailid);
template.print(email);


})(current, template, email, email_action, event);
 
 
When i try to call same email script in notification is coming like this (when i preview email )
 
Aarushi1991_1-1743145652299.pngAarushi1991_2-1743145672477.png

 

 

this email script when i run in background script its giving email id but nt in quick message and notification

 

 

Thanks

 

 

 
 
1 ACCEPTED SOLUTION

@Aarushi1991 - Please refer the screenshot below for the result after using ${current_user.email} in quick message

VasantharajanN_0-1743148909949.png

 


Thanks & Regards,
Vasanth

View solution in original post

12 REPLIES 12

@Aarushi1991 

any static line is working fine in preview?

It should work fine.

I have seen such issues in the past.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

@Aarushi1991 

I believe I have answered your question.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Hello Ankur ,

i appreciate your response

unfortunately i can not test it since i am trying on PDI ,so mail would trigger to mail id

 

but i can see other static and dynamic value are coming other then from

 

Aarushi1991_0-1743152138631.png