- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2014 08:52 AM
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??
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2014 08:51 AM
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).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2014 09:26 AM
Hi Jared,
You aren't able to access 'gs' from the Client. However, you could create a Script Include with a static method (put this logic in that method) and mark the Script Include to be client callable, and then use a client script to call the Script Include to retrieve this information.
Thanks,
Joe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2014 09:36 AM
I have never done any of that before. can you point me in the right direction or elaborate a little bit more?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2014 09:40 AM
Hi Jared,
Yes, please review our Wiki for more information on how to use Script Includes. I have attached a link below.
http://wiki.servicenow.com/index.php?title=Script_Includes
Thanks,
Joe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-14-2014 10:00 AM
Probably doing it way wrong but here is what I did and it isn't working... As if Javascript wasn't finicky enough.. ServiceNow added a whole other level of complexity and ridiculousness.... This is should be a very very simple task but you have to jump through hoops to get it to work right..
Script Inclide:
var CompanyInclude = Class.create();
CompanyInclude.prototype = {
initialize : function() {
},
myFunction : function() {
gs.getUser().getRecord().getValue('company')
},
type : 'CompanyInclude'
};
Client Script Condition:
CompanyInclude != '5c6faa8389a249405f2c0203c80f605c'