- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 11:06 AM
I have an 'onChange' on the priority field, client script. When the priority is changed (record not yet saved) pops up as expected. When the user goes to 'Save / Update' the record, the pop up fires multiple times. This is not an onSubmit, so not understanding why? script below.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (oldValue != newValue) {
//Popup asking user to validate the priority change
if(!g_form.isNewRecord()){
alert('You are changing the priority from ' + 'P' + oldValue + ' to ' + 'P' + newValue + '. Please indicate in additional comments why the priority was changed and who approved.');
}
}
}
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 01:42 PM
That script works perfectly fine in my dev instance. Only fires on Priority change, never onLoad, or onSubmit. Are you sure the Priority change is being written to the dbase and something else isn't going on?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 11:13 AM
OnChange client script run onLoad unless you have this in the beginning of your code:
if (isLoading || newValue == '')
return;
then it will only run onChange.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 11:14 AM
Nice eye. Yea, they took that part out.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 11:39 AM
Updated my code (the '' isn't necessary on my end), but still firing popups when saving record.
What am I missing?
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (oldValue != newValue) {
//Popup asking user to validate the priority change
if(!g_form.isNewRecord()){
alert('You are changing the priority from ' + 'P' + oldValue + ' to ' + 'P' + newValue + '. Please indicate in additional comments why the priority was changed and who approved.');
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2018 12:04 PM
Hmmm . . . your script works fine for me. Only pops up on change. Do you have something else conflicting?