setReadOnly for state not working

Nag89
Tera Contributor

Hello Gurus,

 

It might sound silly; however, I'm unable to set state readonly. I need your help.

 

We handle multiple projects and for one specific project, I want to set the state field readonly. By the way, state is inherited from task table(just for reference).

 

-I wrote UI policy for the following and it isn't working. I've debugged, it's getting into condition; however, not setting the field readOnly.

-I wrote onLoad CS, if state == 'abc', then set readonly. (g_form.setReadOnly and setDisabled aren't working!)Even this isn't working.

-I tried ACL, but it's restricting the write for state field (i want state to be changed as per other field changes).

 

here the catch is that the state field is set to read-only onLoad for 1 sec, then it's becoming editable. I've tried deactivating all other UI Policies, and Client scripts running on state but failed to achieve the result.

 

please provide your valuable suggestions 

@Ankur Bawiskar @Sagar Pagar @Anubhav Ritolia @Ratnakar7 @Aravindhan Sundareswara

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Nag89 

definitely some script is doing that as you mentioned it's becoming read-only for 1 sec

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@Nag89 

definitely some script is doing that as you mentioned it's becoming read-only for 1 sec

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

Yes! there's an onChange script that sets other field read-only is causing this issue. It's because the other field has a condition to set the state editable. I found it and resolved it.. thanks 

Sagar Pagar
Tera Patron

Hi @Nag89,

 

Yes. There may be other client scripts for UI policies on the same field that make it non-read-only

 

Thanks,

Sagar Pagar

The world works with ServiceNow

akin9
Tera Contributor

Hi @Nag89 ,

Can you please confirm the field is mandatory?

If mandatory field then you can uncheck mandatory field and try.