Does a onSubmit Client Script run when Updating a Task vs Closing a Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2020 12:21 PM
I want to manage Mandatory variables in a OnSubmit client script vs UI Policy.
Currently, mandatory variable settings are in UI Policies so if an agent is only updating (vs closing) a task, the mandatory will throw a error message.
If I script the mandatory variables in an "onSubmit" client script, will it run when the agent clicks the UPDATE button vs the "CLOSE TASK" button.
Need a way to allow agents to save work in progress without having to deal with Mandatory verification until Closing the Task.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2020 12:31 PM
Yes, onSubmit will run anytime the record is saved. You could write an onSubmit script that sets those fields to be not mandatory.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2020 12:43 PM
Hi
onSubmit Client Scripts will run right before any change to database values are made so Closing vs Updating will both set it off.
It sounds like you should be able to get your Client Script to do this by just add an IF Statement to the code to check if it is in a closed state. Something like:
function onSubmit() {
if (g_form.getValue('state') == 3) // Assuming 3 is a closed state defined in the dictionary choices / override
g_form.setMandatory('fieldname', true);
}
We recommend using a UI Policy rather than a Client Script like this though.
Hope that helps!
If it did please mark as Helpful and consider setting this reply as the Correct Answer to the question, thanks!