Difference between Glide form setReadOnly() and setDisabled() methods

RameshreddyE
Tera Contributor

Hi,

I have gone through the community and some sources and found that setDisabled() will grays out the field and makes it unavailable. But when i try to apply it, i did not find that functionality. I did it as follows.

 

g_form.setDisabled('short_description', true)

 

So can anyone help me in it...

1 ACCEPTED SOLUTION

MackI
Kilo Sage

Hi @RameshreddyE 

 

You're right, g_form.setDisabled() doesn't directly work on form fields like short_description in the same way it works for variables in a Catalog Item. It's primarily intended for variables within the scope of Service Catalog.

To disable or gray out a field like short_description on a regular form (Incident, Problem, Change, etc.), you need to use different methods depending on whether you're working on the older UI or the newer Next Experience UI (Polaris).
 
 
Recommendation:

For most cases, using g_form.setReadOnly('short_description', true); in your Client Script is the recommended way to gray out and disable the short_description field on a regular form. If you need a no-code solution, use a UI Policy. If you need to control access based on security rules, use an ACL. Remember to test thoroughly in a development instance before deploying to production!
 
Do you need any more specific discussion for this topic .pls let me know
 
If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer‌🌠‌ OR  mark it  Helpful ‌‌ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community
MackI | ServiceNow Developer | 2 *Mainline Certification | LinkedIn Top IT Operation Voice 2023 | Sydney,Australia

View solution in original post

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@RameshreddyE 

difference is explained here

What is difference between setReadOnly() and setDisabled() function? 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

MackI
Kilo Sage

Hi @RameshreddyE 

 

You're right, g_form.setDisabled() doesn't directly work on form fields like short_description in the same way it works for variables in a Catalog Item. It's primarily intended for variables within the scope of Service Catalog.

To disable or gray out a field like short_description on a regular form (Incident, Problem, Change, etc.), you need to use different methods depending on whether you're working on the older UI or the newer Next Experience UI (Polaris).
 
 
Recommendation:

For most cases, using g_form.setReadOnly('short_description', true); in your Client Script is the recommended way to gray out and disable the short_description field on a regular form. If you need a no-code solution, use a UI Policy. If you need to control access based on security rules, use an ACL. Remember to test thoroughly in a development instance before deploying to production!
 
Do you need any more specific discussion for this topic .pls let me know
 
If you like this opinion and your problem is resolved after reviewing and applying it. Please kindly mark this your best answer‌🌠‌ OR  mark it  Helpful ‌‌ if you think that you get some insight from this content relevant to your problem and help me to contribute more to this community
MackI | ServiceNow Developer | 2 *Mainline Certification | LinkedIn Top IT Operation Voice 2023 | Sydney,Australia