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

@Pratap Dalai  any luck on this ?

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

 

Harish KM
Kilo Patron
Kilo Patron

Hi for safer side use the below code in your notification script

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

Regards
Harish

Aman Kumar S
Kilo Patron

Hey,

Try using:

gs.getUser().getRecord().getValue('company'));

 

Feel free to mark correct, If I answered your query.

Will be helpful for future visitors looking for similar questions 🙂

Best Regards
Aman Kumar

@Pratap Dalai 

Did you check my response?

Best Regards
Aman Kumar

@Aman Kumar 

I tried with the bellow script on Scripts - Background ,It works there 

var Compid=gs.getUser().getRecord().getValue('company');

gs.print(Compid);

 

When i tried ,it on Notification email Script ,It does not work

var Compid=gs.getUser().getRecord().getValue('company');

template.print(Compid);  

Thnx