Notification Email Script getCompanyID return null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 10:16 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2022 12:10 AM
template.print(gs.getUser().getCompanyRecord().name);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 10:26 PM
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);
}
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 10:30 PM
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 🙂
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 11:43 PM
Did you check my response?
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 11:58 PM
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