Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

g_form.setDisplay() not working when replacing g_form.setVisible()

armanoj
Mega Sage

 

Hi Community,

I am trying to replace g_form.setVisible() with g_form.setDisplay() in a Client Script.

The existing code using setVisible() works as expected:

g_form.setVisible('field_name', false);

However, when I replace it with:

g_form.setDisplay('field_name', false);

the field is still visible on the form.

I have verified that I am using the correct syntax and the correct field name. The Client Script is executing, and setVisible() works correctly for the same field, but setDisplay() does not seem to have any effect.

Has anyone experienced this behavior?

13 REPLIES 13

@armanoj, 

Check if table and field scope matches the client script scope.

https://www.servicenow.com/community/developer-blog/scoped-applications-and-client-scripts-a-primer/...
This article might explain the issue, check out setDisplay part.

EhabPilloor_0-1791465268668.png

 

Please Accept this response as Solution if it assisted you with your question & Mark this response as Helpful.

 

Kind Regards,

Ehab Pilloor

I'm applying this for form in native view

 

Ankur Bawiskar
Tera Patron

@armanoj 

what type of form is this? native or portal?

screenshots please

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

native view