The CreatorCon Call for Content is officially open! Get started here.

How to make a readonly field as editable for users in particular group

test1231998
Tera Contributor

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

17 REPLIES 17

Hi Ankur,

I tried by using the display br and client script,but i dont see it as becoming non mandatory

find_real_file.png

 

 

 

find_real_file.png

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

sorry that was a typo error,need to make the field non read only

When logged in user is member of si sacm group,need to make the company field as not read only

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader