- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2022 07:53 PM
Hi Community Members,
I am struggling with one part of my requirement, When Job Responsibilities- 'None', then 03 Variables Fields- Task entry, Duties Entry & Responsibilities Entry should be Invisible (Hide) but currently these 03 variable fields are visible (per below Screenshot),
I Used On Change Catalog Client Script on Variable field- Job Responsibilities, its working fine with my other requirements e.g.,- When select choice 'Task', then only Variable 'Task Entry' should become Mandatory & Visible (per below screenshot)
Similarly, when selecting other choices, related variable field becomes Mandatory & Visible (like below Screenshots)
--------------------------------
-------------------------------
-------------------------------------
I Used below mentioned Onchange catalog client script;
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var jobResponsibility = g_form.getValue("job_responsibilities");
if (jobResponsibility == '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);
}
}
-------------------------------------------------
But stuck with only part of requirement i.e., When Job Responsibilities- 'None', then 03 Variables Fields- Task entry, Duties Entry & Responsibilities Entry should be Invisible (Hide) but currently these 03 variable fields are Visible.
Requesting to please provide the revised script to achieve this only part of requirement.
Thanks in advance.
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Service Desk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2022 08:17 PM
Try this -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setMandatory("task_entry", false);
g_form.setDisplay("task_entry", false);
g_form.setMandatory("duties_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("responsibilities_entry", false);
return;
}
var jobResponsibility = g_form.getValue("job_responsibilities");
if (jobResponsibility == '4') { // Value for Choice 'All' is 4
g_form.setDisplay("task_entry", true);
g_form.setMandatory("task_entry", true);
g_form.setDisplay("duties_entry", true);
g_form.setMandatory("duties_entry", true);
g_form.setDisplay("responsibilities_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("task_entry", true);
g_form.setDisplay("task_entry", true);
g_form.setMandatory("duties_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("responsibilities_entry", false);
} 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.setDisplay("task_entry", false);
g_form.setMandatory("duties_entry", true);
g_form.setDisplay("duties_entry", true);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("responsibilities_entry", false);
} 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.setDisplay("task_entry", false);
g_form.setMandatory("duties_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setMandatory("responsibilities_entry", true);
g_form.setDisplay("responsibilities_entry", true);
}
}
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2022 08:17 PM
Try this -
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setMandatory("task_entry", false);
g_form.setDisplay("task_entry", false);
g_form.setMandatory("duties_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("responsibilities_entry", false);
return;
}
var jobResponsibility = g_form.getValue("job_responsibilities");
if (jobResponsibility == '4') { // Value for Choice 'All' is 4
g_form.setDisplay("task_entry", true);
g_form.setMandatory("task_entry", true);
g_form.setDisplay("duties_entry", true);
g_form.setMandatory("duties_entry", true);
g_form.setDisplay("responsibilities_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("task_entry", true);
g_form.setDisplay("task_entry", true);
g_form.setMandatory("duties_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("responsibilities_entry", false);
} 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.setDisplay("task_entry", false);
g_form.setMandatory("duties_entry", true);
g_form.setDisplay("duties_entry", true);
g_form.setMandatory("responsibilities_entry", false);
g_form.setDisplay("responsibilities_entry", false);
} 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.setDisplay("task_entry", false);
g_form.setMandatory("duties_entry", false);
g_form.setDisplay("duties_entry", false);
g_form.setMandatory("responsibilities_entry", true);
g_form.setDisplay("responsibilities_entry", true);
}
}
Thanks,
Sagar Pagar