- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 03:51 AM
Hi,
I have a catalog item where there is a reference variable Requested For to sys_user.
Requested for and some other variables are accessible to every user. I want that only the manager of user whose name is selected in Requested for field can enter values in 8 of the variables, which other users can see but not enter values.
What are ways by which I can achieve this?
1 if writing onChange catalog client script is correct way, then I will have to write it separately for all 8 variables.? Can someone help with the script?
2 if I write an ACL, Can someone help me what condition and script to write so it applies only on 8 variables of my catalog item.
Please help me on how can I do this.
Thanks
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 05:19 AM
Hello ,
I can give a demo script but not sure whether this will help.
Create a onChange Client script on requested for field (Assuming the requested for field is empty on form load)
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('GetManager');
ga.addParam('sysparm_name', 'GetMan');
ga.addParam('sysparm_user_id', newValue);
alert('Script Include');
ga.getXML(userInfoParse);
function userInfoParse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer == g_user.userID){
g_form.setVisible('test',true);// you can make your variables visible here
}
else{
g_form.setVisible('test',false);
}
}
//Type appropriate comment here, and begin script below
}
Now create a Client Callable Script Include GetManager (Check Client Callabe field)
var GetManager = Class.create();
GetManager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
GetMan : function(){
var retvalue ="";
var sn = this.getParameter('sysparm_user_id');
var manager = new GlideRecord('sys_user');
manager.addQuery('sys_id',sn);
manager.query();
if(manager.next())
retvalue = manager.manager.sys_id;
return retvalue;
} ,
type: 'GetManager'
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 04:20 AM
Hello,
You can write one onchange client script on requested for and may be one onload client script. Create a script include to return true or false by checking the logged in user who has opened the form is the manager for requested for user. If it is true you can set all the 8 variables read only to false. If not set those 8 variables read only to true. ACLs will not be helpful here
Regards,
Jagadeesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2019 05:51 AM
Hi Jagadeesh,
Sorry I am not very good at scripting, can you please help me with these scripts ? Also there are two cases - manager for requested for user and user access group- who can access the 8 variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 04:22 AM
Hi remalajagadeesh,
Can you please help me with this?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2019 05:19 AM
Hello ,
I can give a demo script but not sure whether this will help.
Create a onChange Client script on requested for field (Assuming the requested for field is empty on form load)
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('GetManager');
ga.addParam('sysparm_name', 'GetMan');
ga.addParam('sysparm_user_id', newValue);
alert('Script Include');
ga.getXML(userInfoParse);
function userInfoParse(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer == g_user.userID){
g_form.setVisible('test',true);// you can make your variables visible here
}
else{
g_form.setVisible('test',false);
}
}
//Type appropriate comment here, and begin script below
}
Now create a Client Callable Script Include GetManager (Check Client Callabe field)
var GetManager = Class.create();
GetManager.prototype = Object.extendsObject(AbstractAjaxProcessor, {
GetMan : function(){
var retvalue ="";
var sn = this.getParameter('sysparm_user_id');
var manager = new GlideRecord('sys_user');
manager.addQuery('sys_id',sn);
manager.query();
if(manager.next())
retvalue = manager.manager.sys_id;
return retvalue;
} ,
type: 'GetManager'
});