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-14-2022 10:18 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 10:47 PM
No this does not work
template.print(gs.getUser().getCompanyID()); // it stamps null over the email body
This works on Scripts - Background

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 11:10 PM
Hi use the below script in your Notification
var gr = new GlideRecord('sys_user');
if (gr.get(gs.getUserID())) {
template.print(gr.company.name);
}
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2022 11:30 PM
template.print(gs.getUser().getCompanyRecord().name);
Can you try this please?