- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 11:24 AM
What would be the best way to limit field visibility based on the current users location??
It looks like UI Policies only focus around field values which will not work for this.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 03:52 PM
Wow, I am sorry. I should have asked how else I can help you. I will write out an example script for you to use.
Business Rule
g_scratchpad.location= gs.getUser().getLocation();
You access business rules and client scripts by right clicking on the top header bar of whatever table/record you're on.
Client Script
function onLoad() {
if (g_scratchpad.location == '4b7c157437d0200044e0bfc8bcbe5df5'){
g_form.setVisible('<field_name>',false);//Use this if you want there to be an empty spot on the record where the field was
//g_form.setDisplay('<field_name>',false);//Use this if you want to have the field's space filled in once hidden
}
}
Client Scripts - ServiceNow Wiki
That link is for how setVisible works.
This may not be everything that you need, but this will get you in the right direction.
Does this help or do you need more detail? My email is casey.stinnett@crossfuze.com if you want to do a Google + hangout and I can help you out some more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 11:44 AM
Unless I am misunderstanding your problem, then this might be the line you are looking for:
var location = gs.getUser().getLocation();
You can put this in a display business rule that populates the g_scratchpad with the user location and then grab the location value from a client script.
Here is a Cheat Sheet from the ServiceNow Guru about how to use gs. http://www.servicenowguru.com/scripting/user-object-cheat-sheet/
Does that help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 11:53 AM
That's helpful, I just haven't messed with business rules yet so I'll have to read up a bit I guess..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 11:56 AM
Here is the wiki page on Business Rules: http://wiki.servicenow.com/index.php?title=Business_Rules
You will have to click on advanced and make it a display business rule if you are in Eureka. If not, then you can just change it to display in the drop down field for when to run.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 11:57 AM
What is gscratch pad?