- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 05:41 AM - edited 11-13-2023 05:45 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 06:06 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:34 PM
Hi @Ankur Bawiskar ,
the "assigned to" is for the catalog task not a variable of the form
, "Additional E-mail" is a variable only displays on agent:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:36 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:21 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:32 PM
Hi @Amit Gujarathi ,
the "assigned to" is for the catalog task not a variable of the form
So the 'g_form.getValue('assigned_to') ' doesn't work.
Do you know how to get it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:34 PM
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?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader