- 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 12:33 PM
Client Script Best Practices - ServiceNow Wiki
The way that the g_scratchpad works is like an array. Using the example that is used on the page in the link above, you can pass values from the server to the client like this:
Display Business Rule:
g_scratchpad.managerName= current.caller_id.manager.getDisplayValue();
Client Script:
alert(g_scratchpad.managerName);
What is happening here is that when you open up a record on your table that has a display business rule active on it, the business rule runs and fills in g_scratchpad.managerName with a value. Then, when your client script is run, it accesses the g_scratchpad.managerName (which was made available to it from the display business rule when the record was displayed) and alerts that value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2014 02:15 PM
What part tells the specified field not to display? is that something I script into the business rule? This stuff is confusing, learning javascript is confusing enough but then learning where to put your javascript to make it work with this app adds a whole other level of complexity.
- 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-11-2014 10:47 AM
Yes, I am sorry, Jared Wentzel, an ACL is more secure. It was good that prdelong pointed that out. You can still use the script that I gave you.
This is how the script might look for you:
if(gs.getUser().getLocation() == '4b7c157437d0200044e0bfc8bcbe5df5'){
answer = true;
}else{
answer = false;
}
The operation field should be set to "Read". When the user's location is equal to the sys_id of the location(s) you want to check against, then set answer = to true, meaning that if the user's location is right then he/she can see that field. Otherwise, he/she cannot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2014 11:32 AM