How to make a readonly field as editable for users in particular group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2021 04:53 AM
I have a field company on cmdb_ci table which is read only for all users except admin. I want to make this field editable for only those users belonging to a particular group. can anyone please help me with the code or solution
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2021 05:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2021 05:35 AM
Hi,
when logged in user is not member of that SI SACM group is it not becoming readonly
you asked for readonly in your question and not mandatory
you can enhance the logic
g_form.setMandatory('company', false); // 1st make non mandatory then make readonly
g_form.setReadOnly('company', 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
‎04-29-2021 05:38 AM
sorry that was a typo error,need to make the field non read only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2021 05:59 AM
When logged in user is member of si sacm group,need to make the company field as not read only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-29-2021 06:06 AM
Hi,
then the script I shared should work
if that field is mandatory then 1st make it non-mandatory and then make it readonly
if(g_scratchpad.isMember.toString() == 'false'){
g_form.setMandatory('company', false); // 1st make non mandatory then make readonly
g_form.setReadOnly('company', true);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader