- 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
08-14-2018 12:24 PM
Once the submitter updates the record - it will again fires those same pop-ups multiple times. The onchange should occur only during the field being changed, not when the record is updated.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 12:49 PM
A onChange client script runs onChange & onLoad. Adding:
if (isLoading || g_form.isNewRecord()) {
return;
}
to the top of the script prevents it from running onLoad (isLoading) or if it's a new record.
Are you saying you have this in your scripts but they are running onLoad?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 12:55 PM
Correct, my two client scripts, the top both have:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || g_form.isNewRecord()) {
return;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 01:03 PM
Are you sure the pop-ups are caused by these 2 scripts and not another onLoad script? If you inactive these scripts, do you still get the pop-ups?
Can you post your full script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2018 01:20 PM
Full script below. If inactive, issue does not occur.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || g_user.hasRole('admin') || g_form.isNewRecord()) {
return;
}
if (oldValue != newValue) {
//Popup asking user to validate the priority change
alert('You are changing the priority from ' + 'P' + oldValue + ' to ' + 'P' + newValue + '.');
}
}