prevent onChange client script working on onLoad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 09:52 AM
I have the following code added to my onChange client script but it still runs on form load:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// Consider the Empty Duration
if ( isLoading || g_scratchpad.flag || !g_scratchpad.projectTaskSysId) {
g_scratchpad.flag = false;
return;
}
the scratch pad variable projectTaskSysId is set by a Display BR it will contain the task's sys id.
Can some one help me point out how i can disable ithe Client script's execution on form load.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 10:08 AM
What indicator do you have that it is executing? (other than g_scratchpad.flag being set since that will always happen onLoad)
if you want to make sure that it never runs onLoad then change it to:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading)
return;
// Consider the Empty Duration
if ( g_scratchpad.flag || !g_scratchpad.projectTaskSysId) {
g_scratchpad.flag = false;
return;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 11:02 AM
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
//Consider the Empty Duration
if ( isLoading || g_scratchpad.flag || !g_scratchpad.projectTaskSysId) {
g_scratchpad.flag = false;
return;
}
The reason why it is executing is that your IF statement returns true because of the "isLoading" condition. Brian's suggestion should work, if you would not like it to execute when the record loads.
Thanks!