- 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:32 AM
Hi ,
In addition to Anurag code ,you need to add one more line to make field visible as below.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if((oldValue == 1 && newValue ==2) || (oldValue ==2 && newValue == 2))
g_form.setVisible('<Your field>', true);
g_form.setMandatory('<Your field>', true);
}
Thanks,
Pooja M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2023 10:23 AM
Hi Pooja,
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 I used:
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 08:36 AM - edited ‎02-13-2023 08:37 AM
Hi Nirav,
Try below code.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
g_form.setVisible('u_justification_for_priority', false);
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);
}
}
Thanks,
Pooja M
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2023 06:08 AM
Hi Pooja,
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.
- 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