g_form.setValue() does not work for text fields

Steve56
ServiceNow Employee
ServiceNow Employee

Hi,

 

I am using an onLoad script and g_form.setValue() to populate some fields in a catalog form. The fields that are affected by UI policies have interesting behavior. The references and drop downs are working fine. However, the textfields will remain empty with a red border on the field. Does anyone know why this is happening? Also, g_form.setReadOnly() does not work on any field that is affected by a UI policy. Is there any solution to this? Any help is appreciated.

 

Steve56_0-1668714800572.png

 

1 ACCEPTED SOLUTION

Mike_R
Kilo Patron
Kilo Patron

UI policies execute after Client Scripts. On your UI policies actions, are you clearing the variable values? If so, that is likely the reason.

 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/tokyo/servicenow_administrator/app_st...

View solution in original post

2 REPLIES 2

Mike_R
Kilo Patron
Kilo Patron

UI policies execute after Client Scripts. On your UI policies actions, are you clearing the variable values? If so, that is likely the reason.

 

https://developer.servicenow.com/dev.do#!/learn/learning-plans/tokyo/servicenow_administrator/app_st...

Steve56
ServiceNow Employee
ServiceNow Employee

Thanks Mike! After unchecking the "clear value" box, things are working fine now. Even the read only is working now.