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-19-2023 11:31 PM
The script mentioned by you is wrong as you are using oldValue & newValue in onSubmit client script, which is not available OOB as you can see in below screenshot:
the main thing is you don't have any parameter in onSubmit where you get to know whether your assignment group has changed or not!
The best solution as per your scenario is using before-update business rule and I have tried in my PDI and it work really well
Script:
if(!current.comments.changes()){
gs.addErrorMessage('Please insert some comments');
current.setAbortAction(true);
}
Please go ahead with this approach, otherwise we need to make multiple client scripts to handle this scenario and might be it is not possible too
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-20-2023 04:21 AM
Hi! So this is actually locking the entire form even if I add into the Additional comments. I'm not sure if that happened on your end.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 04:24 AM - edited 04-20-2023 04:25 AM
Have you added the above condition?
if(!current.comments.changes())
And make sure you are testing with the Additional comments not worknotes and just write the comments and save the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 04:34 AM
Yes, please see below.
Once I change the assignment group I am not able to update the form, but it is still not accepting even after the comments are updated.
So I am not sure if i should add in g_form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 04:38 AM
Don't post the comments, how the script get to know comments have been added, just type the comments as below and save the record, Once the comments have been posted you can not pick it and this is valid behaviour
comments should be added, when assignment group has been changed otherwise the posted comments would n't be the part of your latest transaction, I hope you get my point!
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.