allow a group to edit a variable in variable editor in ritm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 09:52 AM
I want to allow a group to edit a specific variable in ritm inside variable editor .
the variable is set mandatory in the portal.
How to achieve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2024 12:10 AM - edited 04-06-2024 12:14 AM
Hi @Mouktik_B ,
You can write display business rule to check whether the user is part of that particular group or not .for explanation .I'm considering a scenario like if currently logged in user is a part of CAB Approval group then only the user can edit variables otherwise it will be read only for other users .please refer below display business rule which is checking if the user is part of CAB approval group and it is passing that value to global object scratchpad
(function executeRule(current, previous /*null when async*/ ) {
g_scratchpad.checkUserGroup = gs.getUser().isMemberOf('CAB Approval'); // checking if user is part of CAB Approval Group
})(current, previous);
There is one OOB onload Clint script with name "Variable Editor Readonly" on sc_req_item table which is making these variables read only . I've edited this client script as per below which is making variables read only and editable based on scratchpad values
OOB Client Script
Variables when user is part of CAB Approval Team
function onLoad() {
if (g_scratchpad.checkUserGroup) {
g_form.setReadOnly('please_provide_the_preferred_email_alias', false); // g_form.setReadOnly('variable_name', true);
g_form.setReadOnly('business_justification', false);
} else {
g_form.setReadOnly('please_provide_the_preferred_email_alias', true);
g_form.setReadOnly('business_justification', true);
}
}
This way based on user's group we can make variables read-only or editable
If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful." This action benefits both the community and me.
Thanks,
Astik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2024 01:13 AM
why are you showing variables in portal ? 🙄
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2024 08:18 AM
Hello @Mouktik_B
"Please go through these articles."
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0778416
If you find my response helpful, mark as "Helpful."