- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 11:11 AM
We have our system set up with our company as an Operating company and then different client companies.
On pretty much all the catalog items we have a variable to ask the "Requested For" which has the default value of javascript: gs.getUserID();
I want to restrict the table so that the requested for does not include the operating company (which I have done on the "Type Specifications" tab.)
However when a member of the operating company logs in, although you can not pull down members from the operating company in the drop down, the requested for is still populated with the current logged in user.
Any ideas what I could enter in the default value for this to do "if company is not operating company - get user id, else leave blank"
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 12:56 PM
Oops, it should have been
javascript:if( gs.getUser().getCompanyID() != "COMPANY_RECORDS_SYS_ID" ) { gs.getUserID(); }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 01:26 PM
Hmm, that should work
Run this as a background script and see what you get.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 01:28 PM
Thanks, I will try that tomorrow and report back 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2022 02:33 PM
I found this KBA that may explain why it did not work.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0717013
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 02:06 AM
Thanks, I tested that this morning with fresh eyes (as myself for the operating company) and it worked.
I then got it working for the scenario I needed - i added an else statement too as the issue on the KB article you said seemed to occur. It is now working on Dev so will move across our environments and further test.
Thank you very much for your help.