Populating the Requested For default value in Catalog Item except when the company is a specific company

Amanda37
Tera Contributor

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"

1 ACCEPTED SOLUTION

Oops, it should have been

javascript:if( gs.getUser().getCompanyID() != "COMPANY_RECORDS_SYS_ID" ) { gs.getUserID(); }

 

View solution in original post

8 REPLIES 8

Hmm, that should work

Run this as a background script and see what you get.

if(gs.getUser().getCompanyID() != "COMPANY_RECORDS_SYS_ID") { gs.print(gs.getUserID()); }
gs.print(gs.getUser().getCompanyID());
 

Amanda37
Tera Contributor

Thanks, I will try that tomorrow and report back 🙂

I found this KBA that may explain why it did not work.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0717013

 

Amanda37
Tera Contributor

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.