Conditional mandatory field support
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2025 08:29 AM
Hi Team,
I'm working on the Change module and have a requirement where the Assigned to field on the Change Task should behave as follows:
It should be mandatory for all states when the Organization (from the parent Change Request) is ABC.It should be mandatory only when the state is 'Closed Complete' or 'Skipped' if the Organization is XYZ.
Please note that the Organization field (u_organization) resides on the parent table Change Request, not on the Change Task itself. I’ve implemented the following onLoad client script, but it's not working as expected. Could you please help review and suggest any corrections?
(function onLoad() {
g_form.getReference('change_request', function(parent) {
if (parent) {
var org = (parent.u_organization || '').toString().trim();
enforceAssignedToMandatory(org);
}
}); g_form.onChange('state', function(control, oldValue, newValue, isLoading) {
if (!isLoading) {
g_form.getReference('change_request', function(parent) {
if (parent) {
var org = (parent.u_organization || '').toString().trim();
enforceAssignedToMandatory(org);
}
});
}
}); function enforceAssignedToMandatory(org) {
var state = g_form.getValue('state');
console.log('Org:', org, 'State:', state); // Debugging
if (org === 'ABC') {
g_form.setMandatory('assigned_to', true);
} else if (org === 'XYZ') {
if (state === '3' || state === '4') { // Closed Complete or Skipped
g_form.setMandatory('assigned_to', true);
} else {
g_form.setMandatory('assigned_to', false);
}
} else {
g_form.setMandatory('assigned_to', false);
}
}
})();
Looking forward to your suggestions.
I'm working on the Change module and have a requirement where the Assigned to field on the Change Task should behave as follows:
It should be mandatory for all states when the Organization (from the parent Change Request) is ABC.It should be mandatory only when the state is 'Closed Complete' or 'Skipped' if the Organization is XYZ.
Please note that the Organization field (u_organization) resides on the parent table Change Request, not on the Change Task itself. I’ve implemented the following onLoad client script, but it's not working as expected. Could you please help review and suggest any corrections?
(function onLoad() {
g_form.getReference('change_request', function(parent) {
if (parent) {
var org = (parent.u_organization || '').toString().trim();
enforceAssignedToMandatory(org);
}
}); g_form.onChange('state', function(control, oldValue, newValue, isLoading) {
if (!isLoading) {
g_form.getReference('change_request', function(parent) {
if (parent) {
var org = (parent.u_organization || '').toString().trim();
enforceAssignedToMandatory(org);
}
});
}
}); function enforceAssignedToMandatory(org) {
var state = g_form.getValue('state');
console.log('Org:', org, 'State:', state); // Debugging
if (org === 'ABC') {
g_form.setMandatory('assigned_to', true);
} else if (org === 'XYZ') {
if (state === '3' || state === '4') { // Closed Complete or Skipped
g_form.setMandatory('assigned_to', true);
} else {
g_form.setMandatory('assigned_to', false);
}
} else {
g_form.setMandatory('assigned_to', false);
}
}
})();
Looking forward to your suggestions.
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-22-2025 09:55 AM
Hi @PK14 ,
Please create a UI Policy with the conditions as shown below
Create a UI Action - to make Assigned To mandatory
I believe this should solve your problem.
If my response helped please mark it correct or helpful 🙂