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

Set only the approver groups field of list type field to read-only on Change request form

MehakA
Tera Contributor

I have a list type field on a change request form. I want this field to become read only for all except change managers once the change is submitted.

I am trying to achieve this with the help of onload client script. In that script I have put all conditions and then set the field as readonly by setReadonly as mentioned below. I am not able to use ACL as I have to validate some field values before amking this field as read only

 

g_form.setReadonly('list_type_field', true);
 
Can anyone guide me how I will make this list type field(as mentioned in below screenshot) as read only via client script?
 
List Type Field screenshotList Type Field screenshot

 

 Thanks & Regards,
Mehak Arora
5 REPLIES 5

Nilesh Pol1
Giga Guru

Hi @MehakA ,

Can you try with following script in you client script:

 

if( !gs.hasRole('change_manager') )

{

g_form.setReadonly('list_type_field'true);

}

 

plz mark this helpful/solution accepted, if this note will gets towards the solution.

thanks

Hi @Nilesh Pol1 ,

 

I did like this only but it is not working.

Vishal Birajdar
Giga Sage

Hi @MehakA 

 

Is it typo mistake I don't know but It should be : 

g_form.setReadOnly('list_type_field', true);
 
Another Solution would be :
onLoad script

if (!g_user.hasRole("<role of change manager>")) {
   
/* make field non mandatory in case empty */
    g_form.setMandatory('list_type_field', false);

    /* make field read only */
    g_form.setReadOnly('list_type_field', true);

}
 
 
 
Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

Hi @Vishal Birajdar ,

 

Tried it but no luck.