How to show users only based on logged in user company
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
I want to show only users in a reference variable where company is child or parent.
Example.
Case 1:
I have logged in my company will be BTS, I have another Referance varaible(sys_user) in this variable I want to show all the company users.
Case 2:
I have logged in my company will be AB Mauri, I have another Referance varaible(sys_user) in this variable I want to show only "AB Mauri BeNeFr, AB Mauri Brazil, AB Mauri Etten Leur, AB Mauri India, AB Mauri Italy, AB Mauri Malaysia, AB Mauri Mexico, AB Mauri North America, AB Mauri Pakistan, AB Mauri Philippines, AB Mauri Portugal, AB Mauri Spain, AB Mauri Sri Lanka, AB Mauri Turkey, AB Mauri UAE, AB Mauri Vietnam, Cereform, Mauri Products" company users only.
Note: All this companies are child to AB Mauri.
Case 3:
I have logged in my company will be GSC, I have another Referance varaible(sys_user) in this variable I want to show "AB Nutrition, AWorld, ABakeries, Allied Mills, GG, JR, Speedibake, Westmill " company users only.
Reference Varaible name: Business Users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Could you please give a bit more background.
Are you using any domain separated instances here ?
OR
Are you trying to build a catalog form where based on Company selection , Reference user field value will be populated?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
2nd one
I have a catalog item in that Already variables there, I want to apply data visibility based company of logged in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
If your company variabble name is "varCompany"
then in reference user variable (VarUser), under type specification :
set ref table :sys_user
ref qual: javascript: 'company='+current.variables.varCompany+;
Also Add ref_qual_elements=varCompany in variable attribute of user variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
So in user variable you want to see Users belonging to BTS and users belonging to child company of BTS?
If yes then do this in advanced reference qualifier
javascript: var query = '';
var myCompany = gs.getUser().getCompanyID();
query = 'companyIN' + myCompany + '^ORcompany.parentIN' + myCompany;
query;
I didn't get your Case 3
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
