onSubmit Client Script to make the Add'l comments mandatory based on an Assignment Group change?...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 04:09 PM
Hi All,
I've searched this forum a lot & was not able to find an additional solution. I am hoping that someone can help me with a code for an onSubmit client script.
Originally my task to make the additional comments mandatory based on a change to the assignment group was working but some users were able to bypass the client script if they changed the State field. So I figured an onSubmit client script would be better but I am having trouble with the code.
Original code to previous task below:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if ((newValue != oldValue) && (oldValue != ' '))
{
g_form.setMandatory('comments', true);
g_form.addInfoMessage('Additional comments are required prior to changing the Assignment group.');
}
}
Is it a way I can make this to an onSubmit version?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 05:01 AM
That worked! Thanks! & I have the BR set to 200 since we have a ton, that should be okay? I'll circle back and declare this the solution after testing, I want to make sure the users know to just hit save/update & not post if that makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 05:05 AM
Yes that's okay!
Yes and for second scenario that is completely valid as posted the comments doesn't make sense before updating
Please accept the solution if it has worked for you!
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2023 10:38 PM
function onSubmit(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ag = g_form.getValue('assignment_group');
if ((ag != oldValue) && (oldValue != ' '))
{
g_form.setReadOnly("state",true);
g_form.setMandatory('comments', true);
g_form.addErrorMessage('Additional comments are required when changing the assignment group.');
return false; // stop the form submission
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 04:50 AM
Hi Neel!! This would work but for some reason it is picking up on any change made to the form if you try to update. I changed the code back to "onChange" and added in the read-only field part that you suggested. It's working but I want to make sure with my team is they are okay with the state field being read-only.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if ((newValue != oldValue) && (oldValue != ' '))
{
g_form.setReadOnly("state", true);
g_form.setMandatory('comments', true);
g_form.addErrorMessage('Additional comments are required prior to changing the Assignment group.');
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 03:51 PM
Sure Davis,
After changing the assignment group , you can ask your team if they want the state to automatically change to something so you can set that as well. or your staff can come back to same record and state the state field after saving assignment group changes.