g_form.setDisplay not working for a RITM variable on the backend form using a Client script

Fotios Kossyvas
Tera Contributor

Hi, i am trying to hide a RITM variable on the Servicenow backend form using a Client Script but i cannot find a way to actually do it.

I have these variables showing on the form, the two of them are surrounded by a red box here are part of a variable set called dxc_info

FotiosKossyvas_0-1669710881821.png

FotiosKossyvas_1-1669710966171.png

The variable i am trying to hide is the second one, called more_info

FotiosKossyvas_2-1669711021859.png

The only thing that works is hiding the whole variable set, not just the more_info variable. Of course, i am showing here what works and what not, i am not really hiding the variable set and then trying to hide the single variable 😏

FotiosKossyvas_3-1669711135902.png

i tried the g_form setVisible() method too but it doesn't work too.

Can anyone help me please?

 

 

14 REPLIES 14

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Fotios Kossyvas 

 

Can you check if there are any other client scripts or ui policies for that catalog item or on RITM level.

 

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hi @Voona Rohila , i checked and there are aren't any. I opened a case at Servicenow Support because maybe this is a bug involving non a regular field but a variable one.

Tuan Vu
Kilo Guru

Hi @Fotios Kossyvas , g_form.setDisplay should work. 
I see your script only runs when the page is loaded. Please make sure when you test, your code is executed. 

Hi @Tuan Vu, i verified that my code is executing by putting alerts as debug. It is just that i cannot hide this field, which is defined as variable on a variable set. As i wrote, i can hide the set using g_form.setDisplay but it does not work with this variable. I opened a case at Servicenow Support because maybe this is a bug involving non a regular field but a variable one.

Mitsua
Tera Guru
Tera Guru

Hey @Fotios Kossyvas 

Do you want to do this only by client script? You can achieve the same by using "Catalog UI policy and action".

 

Thanks!

MS.