How to set catalog UI policy's condition as: "Assigned to" of ticket not empty

Junyu
Tera Contributor

Dear all,

 

I am working for maintain item and I have an variable "Additional E-mail" only visible and editable on agent screen.

Now I want to use the UI policy to set on agent screen for the ticket if the "Assigned to" is empty then the "Additional E-mail" should be optional, after filling "Assigned to" then the "Additional E-mail" variable be mandatory, I can't do that in UI policy since I didn't find the condition for "Assigned to", can you show me how to do that?

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Junyu 

catalog UI policy can only add condition on variables and not fields of form.

you can use onLoad normal client script on that table i.e. RITM or sc_task and check the field value and based on that show/hide the variable using this syntax

g_form.setMandatory('variables.variableName' , true);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

9 REPLIES 9

Hi @Ankur Bawiskar ,

the "assigned to" is for the catalog task not a variable of the form

Junyu_1-1699940014289.png

 

, "Additional E-mail" is a variable only displays on agent:

Junyu_2-1699940052868.png

 

 

@Junyu 

you can use onChange client script on assigned_to field on sc_task and then make the variable as mandatory using this syntax

g_form.setMandatory('variables.variableName', true);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Amit Gujarathi
Giga Sage
Giga Sage

HI @Junyu ,
I trust you are doing great.
Please find below reference code

function onLoad() {
    var assignedToField = g_form.getValue('assigned_to');
    var additionalEmailField = g_form.getControl('variables.additional_email');
    
    if (assignedToField === '') {
        // If Assigned to is empty, make Additional E-mail optional
        g_form.setMandatory('variables.additional_email', false);
    } else {
        // If Assigned to is filled, make Additional E-mail mandatory
        g_form.setMandatory('variables.additional_email', true);
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Hi @Amit Gujarathi , 

the "assigned to" is for the catalog task not a variable of the form

Junyu_0-1699939873555.png

So the 'g_form.getValue('assigned_to') ' doesn't work.

Do you know how to get it?

@Junyu 

I already informed above to use normal client script on sc_task in this case

what did you start with and where are you stuck?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader