- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 12:18 PM
Hi guys,
Need a bit of help restricting a newly created field to be seen by members of 7 different user groups.
I don't want to go through ACL so I did a Client script and a script include:
The field gets hidden to everybody
Any advice?
Client Script:
function onLoad() {
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('script_include_name');
ga.addParam('sysparm_name','Restrict_type_of_inc');
ga.getXML(SetVisibility);
function SetVisibility(response) {
var answer = response.responseXML.documentElement.getAttribute("answer") == "true";
g_form.setVisible("variable_name", answer);
}
}
Script Include:
var script_include_name = Class.create();
script_include_name.prototype = Object.extendsObject(AbstractAjaxProcessor, {
script_include_name: function() {
return gs.getUser().isMemberOf('group name here');
},
_privateFunction: function() { // this function is not client callable
}
});
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2017 05:43 AM
i think there is no use of script include and client script, for field hiding simply you can acheive this by using UI Policy.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 12:19 PM
Just curious, why no ACL? That is what they are there for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 12:21 PM
I was advised not to use it.. Would you recommend to do so? If yes, how?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 12:27 PM
Just put a read ACL on the field. In the script portion, say something like:
if(gs.getUser().isMemberOf('Database')){
answer = true;
}else{
answer = false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2017 12:26 PM
I think ACLs might be the better option though it'd have to be roles based and then assign the role to those groups.
Elevate your security rights and right click on the field you want to change the security to like so:
Select the operation and the role you want to have the ability to read.