
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2018 11:06 PM
Hi All,
Is it possible to to make variables editable on catalog task form based on user roles by using Client Script??...
The requirement is some variables should be editable for ITIL users
Can someone help me with this?
Thanks and Regards,
Angshuman
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2018 11:13 PM
Yes, It is possible. You can write a client script like if user has role set field to writable else readable.
var rqdrole = g_user.hasRole('RoleName');
if (rqdrole){
g_form.setReadonly('fieldname',false);
}
Hope this helps.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2018 10:06 PM
Sure...!!
Even your information was helpful for me...!!
Thanks for that too, if it helped you do mark it helpful...!! 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2018 10:09 PM
I asked to know what did you manipulate to make it work. However logic is quite similar.
Thank you! 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-17-2019 04:21 AM
Hi,
I have similar kind of requirement to make variables editable on catalog task form. I tried below code :
if(item =="CATALOG_ITEM_NAME" ) {
g_form.setVariablesReadOnly(true);
g_form.setReadOnly("variables.VARIABLE_NAME",false);
}
but its not working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2020 03:40 AM
Hello Angshuman
You may wirte catalog client script for it.
My catalog tasks needed different fields to appear and also different fields to be made read-only for each task.
1. select "Applies on Catalog Tasks" before you start
2. I have considered the short description field as the identifying factor of my task:
my code is as follows:
"
function onLoad() {
var taskList = new GlideRecord('sc_task');
taskList.addQuery('short_description','XXXXX_Task');
taskList.query();
if(taskList.hasNext()){
g_form.setReadOnly('field1',false);
g_form.setMandatory('field1',true);
}
else{
g_form.setReadOnly('field1',true);
g_form.setMandatory('field1',false);
}
}
"
3. One thing has to be noted, when I did not add setMandatory it was not working but it worked once I added it.
Please let me know if if anyone knows the reason why it only works with mandatory field and also if anybody has a better approach of achieving the same.