Set Variables readonly on RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-27-2021 07:35 PM
Hi Community
I need help for the below requirement
I want to make the variables read-only on the RITM form. I wrote a UI policy on the RITM table please find it below
This is working, but I have some variables for which the "Name" starts with "Edit_" should be editble on the RITM.
I have tried the below code, but it is not working
g_form.setReadOnly('variables.nameLIKEEdit^active=true','false');
Can you please help me if there is a way to fix this
Thanks in advance
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2021 12:53 AM
Glad to know that my script worked.
Please mark my response as correct and close the question.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2021 12:54 AM
Hi,
So in that UI policy add condition
Assignment Group [IS NOT] Group ABC
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2021 12:58 AM
Hi
But here the variables should be editable on RITM level. So when the logged in user is member of GROUP ABC, variables of that catalog item should be editable for the members of the logged in group
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2021 01:27 AM
Hi,
okay group membership is required.
then that you cannot do using UI policy; remove that UI policy
Please use display BR on sc_req_item table
g_scratchpad.isMember = gs.getUser().isMemberOf('Group ABC');
Then use onLoad client script on sc_req_item table
function onLoad(){
// if not member then make variables readonly
if(g_scratchpad.isMember.toString() == 'false')
g_form.setVariablesReadOnly(true);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2021 01:36 AM
Hi
This will break the script mentioned below. I am so sorry for the inconvenience but this is where I stuck
function onLoad() {
$("variable_map").querySelectorAll("item").forEach(function(item){
var variable = item.getAttribute("qname");
if(!variable.startsWith('edit')){
// if not starts with edit then make those readonly
g_form.setReadOnly("variables."+ variable, true);
}
});
}
Thanks in advance