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

Anil Lande
Kilo Patron

Hi,

Please try only below:

g_form.setDisplay('more_info',false);

 

Comment or remove the line:

g_form.setDisplay('variables.more_info',false);

 

If this line throws error next line will not execute.

 

 

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Fotios Kossyvas
Tera Contributor

Hi Anil Lande, i have already tried that, it just don't work. Either of these ways don't work.

I have inserted them on the script just to show what i had tried.

Mohith Devatte
Tera Sage
Tera Sage

Hello @Fotios Kossyvas ,

Can you try creating a Catalog UI policy and check the check box "Applies to RITM" and make the catalog UI policy action for that variable visible false.

 

is this feasible or you have to check few conditions before making it visible false?

 

Hope this helps 

Mark my answer correct if this helps you 

Thanks

Hi @Mohith Devatte , i have to check conditions  before making it visible false.

In fact, i am using a business rule where i code these conditions and set a scratchpad variable. Then on the Client script i check the value of this variable so i can hide the field.

I tried to see if i can use a Catalog UI policy to do it but i miss these conditions this way.