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 02:39 AM
Can you please share screen shot of field on dictionary,UI Policy, form and the form layout?
Stay awesome,
Roshnee Dash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 02:50 AM
Hi @ahmed-24, try the script I have shared, also disable any other customization to see if it works properly or not.
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-20-2025 03:54 AM - edited 06-20-2025 04:49 AM
Okay But as I can see here on the UI policy you have check Onload.
So based on your work this will run onload and that time its checking the script.
As I can also see we cant apply the direct chnage condition for Assigned to field from UI policy
But as per the requirement you can do like this:-
Create a Client Script:-
1.Name:-Set Reassignment Reason
2.Table:-Incident
3.Type:-Onchange
4.Field:-Assigned
5.Script:-
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
var newAssignee = g_form.getValue('assigned_to');
if (newAssignee != oldValue) {
// Show the Reassignment Reason field
g_form.setValue('u_reassignment_reason','');
g_form.setDisplay('u_reassignment_reason', true);
// Make it mandatory
g_form.setMandatory('u_reassignment_reason', true);
// Optionally, clear the field to force new input
g_form.setValue('u_reassignment_reason', '');
} else {
// Hide the field if Assigned to is cleared
g_form.setMandatory('u_reassignment_reason', false);
g_form.setValue('u_reassignment_reason', '');
g_form.setDisplay('u_reassignment_reason', false);
}
}
Stay awesome,
Roshnee Dash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2025 04:17 AM
@Roshnee Dash The problem that the field is still visible before/after updating the assigned to. and the requirement is that field must appears just when we update the assign to