How to make a field readonly when certain field value changes from the oldvalue ?

ABHI08
Tera Contributor

Need to make a field readonly when the value changes for the first time to avoid multiple changes

7 REPLIES 7

kaushal_snow
Mega Sage

Hi @ABHI08 ,

 

Create a onchange client script on that particular field.

 

if (oldValue && oldValue !== newValue) {
g_form.setReadOnly('your_field_name', true);

 

Above script ensures that once a field’s value differs from its stored oldValue, it will make field read only immediately.

 

Try this once and let me know. If you find this helpful, please accept this as a solution and hit the helpful button..

 

 

Thanks and Regards,
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/

It is making the field read only for the time being when the field value is changed but after saving the form it  again becomes editable. I want the field to be editable after the change occured for the first time

AndersBGS
Tera Patron
Tera Patron

Hi @ABHI08 ,

 

Can you try to describe your requirement a little deeper than what you have done? What is the business case that you have? 

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/