The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Condition on Client Script

jared_wentzel
Kilo Contributor

I am trying to set a condition on a client script so it will run for all users except for those with a specific company value set on their user account... and I cannot figure out what I am doing wrong!

Condition:

gs.getUser().getRecord().getValue('company') != 'CompanySysID'

Any Suggestions??

1 ACCEPTED SOLUTION

I would move the condition into the script itself:



if (g_scratchpad.userCompany.... (ps you had a typo in the screenshot example condtion, so fixing that might just work).


View solution in original post

13 REPLIES 13

I would move the condition into the script itself:



if (g_scratchpad.userCompany.... (ps you had a typo in the screenshot example condtion, so fixing that might just work).


Looks like a typo in the condition g_scratchpad vs g_scrachpad


Mike Allen
Mega Sage

Also, you can use gs.getUser().getCompanyID() to return the company's sys_id:



Getting a User Object - ServiceNow Wiki


jared_wentzel
Kilo Contributor

Alright, finally got it working. Thank you guys for all the help!



I fixed the typo and added the condition to the script itself rather than the condition line. For some reason a condition doesn't work in a condition line.... ( -__- )