The CreatorCon Call for Content is officially open! Get started here.

Catalog item variable not evaluating 'javascript: gs.getUser().getCompany()'

kc99
Giga Expert


Hi,

I wonder if anyone can help with this problem.

We have a catalog item that includes a variable set which displays a 'requestor name' and the related 'requestors company'.

The 'requestor name' is evaluated correctly and displays on the item form with a default value of 'javascript: gs.getUserID()'.

However, the 'requestors company' is not evaluated using 'javascript: gs.getUser().getCompany()' when the form loads - this script uses the syntax recommended in several posts on the community.

company_variable.png

Does anyone know why this could be - is it the ordering of the variables on the form?

I can spend some time on creating another client script to populate this field but I wanted to check why this is not working,

many thanks,

Keiron.

1 ACCEPTED SOLUTION

rajesh73_k
Kilo Expert

try this:



javascript:gs.getUser().getCompanyID()


View solution in original post

14 REPLIES 14

This is how the variable should be defined



find_real_file.png


Thanks Kalai,


I've just tried this instead of having the code in the default value but still no luck.


Could this be affected by any ACL on the Company field?


Does the user record has the company field filled in ? what records are you getting on clicking the lens icon ?


Also login to


url: demo023.service-now.com/login.do


username and password : admin



access service catalog > blackberry


Thanks again for taking the time to help Kalai.



I see that this works ok and that I am presented with the correct Company for the logged-in user.



There is obviously something wrong with the permissions (or domain separation issues ??) in our instance because I don't see anything when clicking on the spyglass icon for the Company field.



The only difference with my form is that it is intended to display the user name and the Company on load of the page as read-only fields.



It only appears to be the Company field that we are having the problem with so I'll look into this further.