- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2025 05:20 AM
// Load the user record from customer_contact table
var user = gs.getUserID();
var userGR = new GlideRecord('customer_contact');
userGR.get(user);
var parentAccountName = userGR.account.account_parent.name + '';
var targetAccountName = 'Test Super Parent 001';
var answer = (parentAccountName == targetAccountName);
Not sure why this script is not working.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2025 11:19 PM
This script worked
var answer = false;
targetAccountName = "Test Super Parent 001";
var userGR = new GlideRecord('customer_contact');
userGR.addQuery("sys_id", user_id);
userGR.addQuery("account.account_parent.name",targetAccountName);
userGR.query();
answer = userGR.hasNext();
The issue was caching. Everytime before I impersonate someone, I had to do cache.do and then impersonate to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2025 06:48 AM
in background script you passed which contact user's sysId?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2025 11:19 PM
This script worked
var answer = false;
targetAccountName = "Test Super Parent 001";
var userGR = new GlideRecord('customer_contact');
userGR.addQuery("sys_id", user_id);
userGR.addQuery("account.account_parent.name",targetAccountName);
userGR.query();
answer = userGR.hasNext();
The issue was caching. Everytime before I impersonate someone, I had to do cache.do and then impersonate to make it work.
