- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2023 09:02 AM
Hi,
I have added a field called "u_justification_for_priority" (label: Justification for priority) on incident form. I want it to be mandatory and visible only if someone downgrades the priority from P1 or P2.
How do we achieve it?
I have tried Ui policy but UI policy does not seems to help as there is no option like priority changes to or there is no other option which can use. Please help.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 07:24 AM
Hi Nirav,
Please try this.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if ((isLoading) && (g_form.getValue('u_justification_for_priority') == '')) {
g_form.setVisible('u_justification_for_priority', false);
return ;
}
//Type appropriate comment here, and begin script below
if((oldValue == 2 && newValue == 3)||(oldValue==2 && newValue==4))
{
g_form.setVisible('u_justification_for_priority', true);
g_form.setMandatory('u_justification_for_priority',true);
}
else if(g_form.getValue('u_justification_for_priority') == '')
{
g_form.setMandatory('u_justification_for_priority',false);
g_form.setVisible('u_justification_for_priority', false);
}
}
Thanks,
Pooja M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2023 09:09 AM
You should be able to do this vai Onchange client script and compare the oldValue and newValue of priority
Something like below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if((oldValue == 1 && newValue == 2) || (oldValue == 2 && newValue == 3))
g_form.setMandatory('<Your field>', true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2023 10:13 AM
Hi Anurag,
I added your script but it is also getting mandatory if i change priority from P4 to P2 or P4 to P1 (upwards) which should not be.
I just want it to be mandatory and visible if priority is decreased from P2 ->P3 or P3->P4. Secondly how do I hide it from incident form view currently it's visible on form.
script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if((oldValue == 2 && newValue == 3) || (oldValue == 2 && newValue == 4))
g_form.setVisible('u_justification_for_priority', true);
g_form.setMandatory('u_justification_for_priority', true);
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2023 02:32 AM
Use this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if((oldValue == 2 && newValue == 3) || (oldValue == 2 && newValue == 4))
{
g_form.setVisible('u_justification_for_priority', true);
g_form.setMandatory('u_justification_for_priority', true);
}
else
{
g_form.setMandatory('u_justification_for_priority', false);
g_form.setVisible('u_justification_for_priority', false);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 06:07 AM
Hi Anurag,
The field is getting mandatory and Visible during downgrading priority from P2-> P3 but the issue here is once data is entered to mandatory field "Justification for Priority" and once form is saved the "Justification for Priority" remains hidden.
The field "Justification for Priority" should be visible once it's filled.