Make field read Only after submission

riaz_mansuri
Kilo Guru

Hi,

I have added a new Choice Field on my Change Request form called Submitted As and is open for users to select a drop down option.

Once the change has been submitted I was this field to become Read Only.

A change would be classed as submitted when the state changes to Open or is Work In Progress.

Any Ideas?

Thanks

Riaz

1 ACCEPTED SOLUTION

riaz_mansuri
Kilo Guru

Thanks for all your help.



I ended up with a simple UI Policy which changes it to Read Only when the state is not Draft.



This is fine for us.



Thanks,


Riaz


View solution in original post

7 REPLIES 7

Chuck Tomasi
Tera Patron

Hi Riaz,



This requires an ACL (security rule)



You can use the GlideRecord method isNewRecord() to determine if the record has been saved or not. In you case, you want to grant the field write permission if current.isNewRecord().



Docs: Access control rules


Docs: Contextual security  


Security Best Practices - ServiceNow Wiki


I think this is the correct answer. If we look into from the security standpoint, ACL is actually restricting the field from editing in the database, rest all are client side restriction.

Sharique Azim
Kilo Sage

Hi Riaz,



You can use a onLoad Script with conditions,


if(g_form.isNewRecord){


g_form.setReadOnly('field_name',false);


}


else{


g_form.setReadOnly('field_name',true);


}



Regards,


Shariq


Mark correct and helpful if it works


Keep in mind that client side security is not secure. A clever user with a minimum of browser knowledge can change a read-only field that has been set with client scripts or UI policies. To ensure compliance, use server side security whenever possible.