Can not set display to false client script

codedude
Mega Expert

I have a field on my sc_req_item table. I am displaying this field on a catalog task. I am trying to hide this field with certain tasks and show with others. I am using this as my script:

g_form.setDisplay('sc_task.request_item.u_choose_a_pc', false);

This line is not working, maybe because of the dot walking? I have used this hundreds of times, but not in this case where I am hiding it from dot walking.

I am using this line in the same script and it works fine, also not dot walking with this one:

g_form.setDisplay('u_stockroom', true);

Can anyone tell me why the first scenario is not working and how I can achieve this in a client script?

4 REPLIES 4

Deepak Kumar5
Kilo Sage

Dot walking is not supported by client side script. so it is not working in first case.


If you are hiding the Variables on TASK, YOU can write a catalog client script on that item and click on applicable on TASK only.



If you are hiding RITM field value, You can create a UI policy on TASK.


Deep K is right, you can't dot.walk in a client script, that is server side functionality.



I would suggest that you use an Ajax call to get the information you need from the server (Script Include) if the requirement is for an onChange field.


Otherwise I would recommend using a display business rule to put the necessary information on the g_scratchpad to be readily accessible in your client script.



Examples of asynchronous GlideAjax



Kind Regards,


Stefan


stefan_ojeblom
ServiceNow Employee
ServiceNow Employee

Make sure the field is not made mandatory in a UI Policy or Client Script somewhere else.


Mandatory is mutually exclusive with display false.


Kalaiarasan Pus
Giga Sage

Can you try using this?



g_form.setDisplay('request_item.u_choose_a_pc', false);