UI policy

Rishabh_N
Tera Contributor

Hi everyone,
I have 3 UI Policies, and each of them contains around 8–9 UI Policy Actions (show/hide and mandatory conditions for variables). But the UI Policies are not working as expected.

I already checked the Order and also tried Reverse if false, but it’s still not working properly.

(It is for catalog item)

2 ACCEPTED SOLUTIONS

@Rishabh_N 

 

I can see your screenshots.

The issue happens because you are using the same variable in multiple UI Policies.

 

For example, the variable “department” is set to mandatory = true in one policy and mandatory = false in another. This is not correct, because when the request is created, the variable will always follow the first policy, and for other request types it will conflict.

 

Instead of creating separate UI Policies that contradict each other, you should create a single UI Policy with conditions combined using AND (and/or OR when needed).

This way the logic will be consistent, and the variable will only behave as expected based on the right conditions.

 

 

See  Allen explanation 

 

https://www.servicenow.com/community/developer-forum/catalog-ui-policies-and-multiple-choice-variabl...

View solution in original post

prerna_sh
Mega Sage

Hi @Rishabh_N 


As you are setting 3 Ui policies for the same variable. As per servicenow, "setting the same variable as mandatory in one UI Policy and not mandatory in another" creates a conflict, and ServiceNow will only allow one state at a time, usually whichever UI Policy runs last, or which one is at higher precedence takes effect.
It is recommended to use "AND/OR conditions" in a single UI Policy to define your requirement, as @Rafael Batistot mentioned.


Please go through:
https://www.servicenow.com/docs/bundle/zurich-servicenow-platform/page/product/service-catalog-manag...
https://www.linkedin.com/pulse/conflicting-ui-policies-dan-covic/
https://support.servicenow.com/kb?id=
kb_article_view&sysparm_article=KB0551679

---------------------------------------------------------------------------------------------------------------------------------------------------

If my response solves your query, please marked helpful by selecting Accept as Solution and Helpful. Let me know if anything else is required.

Thanks,

Prerna

View solution in original post

13 REPLIES 13

shyamkumar VK
Kilo Patron

@Rishabh_N 
What’s not working can you share the screenshots for more understanding 

 

Along with this check if that policies are Activated

 

Regards,

Shyamkumar

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

Sharing screenshots. could you please let me know if i have set up anything incorrectly?

AbinC
Tera Contributor

Hi @Rishabh_N ,

 

Hello Rishabh,

This is happening because you have I believe 3 UI policies and hence they are conflicting with each other. I would suggest you to create a single UI policy with the below condition:

Condtion: Job responsibility is one of Task, Duties, Responsibilities, All

In Execute if true: Please replace the correct field name and field Values (like All, Task, Duties backend value)

var jobResponsibility = g_form.getValue("job_responsibility");
if (jobResponsibilty == "All") {
g_form.setDisplay("task_entry", true);
g_form.setDisplay("duties_entry", true);
g_form.setDisplay("responsibilities_entry", true);
g_form.setMandatory("task_entry", true);
g_form.setMandatory("duties_entry", true);
g_form.setMandatory("responsibilities_entry", true);
} else if (jobResponsibility == "Task") {
// While hiding the fields you first need to set Mandatory as false and then set Display as false;
g_form.setMandatory("duties_entry", false);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setDisplay("responsibilities_entry", false);

g_form.setDisplay("task_entry", true);
g_form.setMandatory("task_entry", true);
} else if (jobResponsibility == "Duties") {
// While hiding the fields you first need to set Mandatory as false and then set Display as false;
g_form.setMandatory("task_entry", false);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("task_entry", false);
g_form.setDisplay("responsibilities_entry", false);

g_form.setDisplay("duties_entry", true);
g_form.setMandatory("duties_entry", true);
} else if (jobResponsibility == "Responsibilities") {
// While hiding the fields you first need to set Mandatory as false and then set Display as false;
g_form.setMandatory("task_entry", false);
g_form.setMandatory("duties_entry", false);
g_form.setDisplay("task_entry", false);
g_form.setDisplay("duties_entry", false);

g_form.setDisplay("responsibilities_entry", true);
g_form.setMandatory("responsibilities_entry", true);
}

in Execute if false:

g_form.setMandatory("task_entry", false);
g_form.setMandatory("duties_entry", false);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("task_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setDisplay("responsibilities_entry", false);

Please mark my respsone as helpful/correct, if it answer your question.

Thanks

Abin chacko. 

Rafael Batistot
Kilo Patron

Hi @Rishabh_N 

 

Could you please share more details? For example:

– Which variables you are trying to hide/show or make mandatory.

– The exact conditions you are using in the UI Policies.

– Whether the issue occurs on the catalog item form or on the RITM form.