How to hide mandatory fields

Saridha_L1
Tera Expert

Hi Team,

I am unable to hide the mandatory field using UI Policy. Because there is a variable set ,using the same field for 5 different items. can anyone help me

Regards,

Saridha.L

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

As other suggested UI Policy is good option where you can select the particular catalog item and then based upon variable value changes you can to set the field behavior. You can build the condition. I think when you are selecting the Catalog item then it should not impact other catalog item if they are referring the same variable set.



find_real_file.png


if there is any issue with UI Policy then give a try with catalog client script if that helps. Simple Sample Script (change the field_name accordingly)



function onChange(control, oldValue, newValue, isLoading) {


if (isLoading || newValue == '') {


return;


}


if(newValue == 'PUT THE FIELD VALUE HERE'){


g_form.setMandatory('field_name', false);


g_form.setDisplay('field_name', false);


}


else{


g_form.setMandatory('field_name', true);


g_form.setDisplay('field_name', true);


}


}


View solution in original post

12 REPLIES 12

Hi Saridha,



As you made the field as non-mandatory , you should be able to hide it. But since you said another UI policy is also there on the same field , you need to ensure that the logic is not overriding by the other UI policy, which you can manage by order field value.


For any reason, if you still having issues managing your logic with UI policies, you can go for below logic. But remember, handling with UI policies is the best practice and the below client script is advisable only when you cannot directly manage with UI policy.



client script :


g_form.setVisible('field_name_here', false);



Regards


Srinivasa Reddy Neelapu


********************************


Please mark response with a Like, Helpful or Correct


Hi Srinivas,



Thank you for your response.



As you suggested I have tried, still it didnt work.



Regards,


Saridha.L


The SN Nerd
Giga Sage
Giga Sage

Is this in Service Portal or Fulfiller interface?


I've noticed they process order of UI Policies differently under some circumstances.



ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Gowrisankar Sat
Tera Guru

Can you make sure that "Applies on a Catalog Item View" is checked?



If checked, check if there are any other UI Policies running at the same or higher order.



If no UI Policies found, then make the mandatory field false and try hiding the field using UI Policy actions.



If any of these doesn't work, try using Catalog Client Scripts, which is a closer alternate to UI Policies.


Hi Gowrisankar,



There is an another UI Policy running for the same field.