New field (Reassignment Reason) is visible/mandatory when assigned to is updated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2025 08:22 AM
i want to create a new field (Reassignement reason) which is (Visibile/mandatory) when the assigned to is updated
Icreate a UI Policy whith script; i also create a client script. But it's not working!!
Help please.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 06:06 AM
You should Change the UI Policy Action from Visible - Leave Alone to Visible - False.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:29 AM - edited 06-20-2025 02:33 AM
Hi @ahmed-24,
function executeRule(gForm, gUser, gSNC) is not needed in the script.
Also you need to put setMandatory false after setDisplay in else condition as setting display false is nullified due to field still being mandatory.
Also your Glide Form method used is wrong
Try this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var originalAssignedTo = g_form.getValue('assigned_to');
g_form.setMandatory('u_reassignment_reason', false);
g_form.setDisplay('u_reassignment_reason', false);
if (newValue != oldValue) {
g_form.setDisplay('u_reassignment_reason', true);
g_form.setMandatory('u_reassignment_reason', true);
} else {
g_form.setMandatory('u_reassignment_reason', false);
g_form.setDisplay('u_reassignment_reason', false);
}
}
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2025 01:46 PM
Hi @ahmed-24 ,
Can you please share some more information? What have you configured? Can you share your configuration?
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:25 AM
Please share the snippet of UI policy.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 03:23 AM
Hello @ahmed-24 ,
To ensure the "Reassignment Reason" field becomes visible and mandatory only when the "Assigned To" field is updated, you'll need to combine a UI Policy and a Client Script.
Here's how to implement it:
1. UI Policy: Initial Field Visibility
First, configure a UI Policy to set the default visibility of the "Reassignment Reason" field to false. This ensures it's hidden when the form initially loads.
- Field: u_reassignment_reason
- Visibility: Set to false
2. Client Script: Dynamic Visibility and Mandatory State
Next, create an onChange Client Script that triggers when the "Assigned To" field is modified.
- Name: (e.g., "Show/Hide Reassignment Reason")
- Table: (The table your form is on, e.g., incident, sc_req_item, etc.)
- Type: onChange
Field Name: assigned_to (assuming this is the backend name of your "Assigned To" field)
Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.
Thanks and Regards,
Ved