Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Catalog UI Policy not working as required (Explained in Description)

rishabh31
Mega Sage

Respected Community,

When Selecting 'Task' (Choice) in Variable Field- Job Responsibilities, then only a Variable field- 'Task entry' becomes Mandatory & Visible.

find_real_file.png

*Outcome (Achieved but with Gap below)- 

find_real_file.png

When Selecting 'Duties' (Choice) in Variable Field- Job Responsibilities, then only a Variable field- 'Duties entry' becomes Mandatory & Visible.

find_real_file.png

*Outcome (Achieved but with Gap)-

find_real_file.png

When Selecting 'Responsibilities' (Choice) in Variable Field- Job Responsibilities, then only a Variable field- 'Responsibilties entry' becomes Mandatory & Visible.

find_real_file.png

*Outcome (Achieved but with Gap)-

find_real_file.png

& When Selecting 'All' (Choice) in Variable Field- Job Responsibilities, then all three Variable fields- 'Task entry', 'Duties entry' & 'Responsibilties entry' becomes Mandatory & Visible.

find_real_file.png

*Outcome (Not Achieved as Duties Entry Missing, Sometimes its Visible & many times NOT)-

find_real_file.png

I tried to achieve this by UI Actions OR UI Scripts also, but not getting results, please help me with revise script or process, I will be thankful!

Thanks in advance

1 ACCEPTED SOLUTION

OR else I believe you can achieve this using UI policy actions as well with below conditions in UI policy. you can create 3 UI Policies with details mentioned below:

Keep

On load : checked (on all UI Policies)

Reverse if false : checked (on all UI Policies)

1. UI policy for Task:

Condition - Job Responsibilities IS Task OR ALL

In UI policy actions - Task entry :  mandatory - true, visible - true

2. UI policy for Duties:

Condition - Job Responsibilities IS Duties OR ALL

In UI policy actions - Duties entry: mandatory - true, visible - true

3. UI policy for Responsibilities:

Condition - Job Responsibilities IS Responsibilities OR ALL

In UI policy actions - Responsibilities entry: mandatory - true, visible - true

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

Thanks

View solution in original post

7 REPLIES 7

@Mahendra  Sir, Thanks but Coding is Not working for any of field, can you please help me with below code (I modified field value & name), please help with this

*Execute if True-

function onCondition() {
var jobResponsibility = g_form.getValue("job_responsibilities");
if (jobResponsibilty == '4') { // Value for Choice 'All' is 4
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 == '1') { // Value for Choice 'Task' is 1
// 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 == '3') { // Value for Choice 'Duties' is 3
// 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 == '2') { // Value for Choice 'Responsibilities' is 2
// 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);
}
}

*Execute if False-

function onCondition() {
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);
}

 

Sagar Pagar
Tera Patron

Hi,

I would suggest to add UI policy actions instead of scripts in UI policy. disable the existing UI polices you have written.

 

You have to write 3 UI policies for this as follows:

UI policy 1:

Condition - Job Responsibilities IS Task

UI policy action - Task entry :  mandatory - true, visible - true

 

UI policy 2:

Condition - Job Responsibilities IS Duties

UI policy action - Duties entry: mandatory - true, visible - true

 

UI policy 3:

Condition - Job Responsibilities IS Responsibilities

UI policy action - Responsibilities entry: mandatory - true, visible - true

 

Try this as let me know the results!

Thanks,

Sagar Pagar

The world works with ServiceNow

Nikita Kale
Giga Guru

Hi Rishabh

Create 3 UI Policies as below: 

UI Policy 1

find_real_file.png

 

UI Policy 2 

 

find_real_file.png

 

UI Policy 3

 

find_real_file.png

 

Please mark the response as helpful/correct, if it answers your question.

 

Thanks

Nikita