- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 08:58 AM
Hello All,
Appreciate your help in this client script.
My requirement is to make Assignment group on a project task form mandatory, only when assigned to is filled in.
I wrote a client script for this, but find it not working when assigned to is empty.
1. When Assigned to is empty, Assignment group is empty - Able to submit.
2. When Assigned to is filled, Assignment group is empty, Error message shows up as expected.
3. When I fill in the assignment group, the Error message still shows up.
This is my client script. Could you please let me know what could be wrong?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 09:11 AM
You can easily write UI Policy rather than script on project task form.
When to run : Assigned To is not empty
Then go to UI Policy Actions, find Assignment Group field, make Mandatory true and the rest leave as It is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 09:02 AM
Try this:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 09:03 AM
or an onChange script this this code in it:
if(g_form.getValue("assigned_to") != ""){
g_form.setMandatory("assignment_group",true);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 09:11 AM
You can easily write UI Policy rather than script on project task form.
When to run : Assigned To is not empty
Then go to UI Policy Actions, find Assignment Group field, make Mandatory true and the rest leave as It is.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 09:42 AM - edited ‎08-07-2024 09:45 AM
Hello @Shree Nag ,
UI Policies --> You can achieve this scenario with just 2 steps.
Conditions: current.assigned_to != ' ';
UI Policy Actions: Check the box to make the field mandatory when the condition is met
Client Script --> onChange
(function executeRule() {
// Check if Assigned To field is filled
if (g_form.getValue('assigned_to') != '') {
// Make Assignment Group field mandatory
g_form.setMandatory('assignment_group', true);
} else {
g_form.setMandatory('assignment_group', false);
}
});
If you found my response helpful, please consider marking it as "Helpful" or "Accept Solution." Thank you!