Notification Email Script getCompanyID return null

Pratap Dalai
Kilo Explorer

Hi All,

I have built notification email script

    var GU_obj=gs.getUser();  
    var compid=GU_obj.getCompanyID();
    template.print(compid);

I have tested this on "Scripts - BackGround",It returned the value as well. 

I have called the script from email Notification body,When user received the email ,They received the value as null.

thnx.

19 REPLIES 19

Mohith Devatte
Tera Sage
Tera Sage

Hello,

Can you try this ?

template.print(gs.getUser().getCompanyID()); -->this actually prints the sys_id of the  company but if you want the name of the company please use below one 

template.print(gs.getUser().getCompanyRecord().name);

Please mark my answer correct if it helps you 

 

No this does not work

template.print(gs.getUser().getCompanyID());   // it stamps null over the email body

 

This works on Scripts - Background 

Hi use the below script in your Notification

var gr = new GlideRecord('sys_user');
if (gr.get(gs.getUserID())) {
   template.print(gr.company.name);
}

Regards
Harish

template.print(gs.getUser().getCompanyRecord().name);

Can you try this please?