- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 09:58 AM
Hello Community.
I am stuck at piece of development. On my onChange Client Script below; I am trying to vet and see if the user is Authenticated to close a Release Task, and confrim if the user wants to Close Complete(State = 3 for close complete, and onChange is tied to the State field) a release task.
The client script works as intended for majority of Release Tasks closures, however for a handful of Release Tasks this script is executing twice, meaning the confirm pop-up is showing up twice.
I am not sure why this is the case. Does anyone have any ideas on simple remediation?
Much Thanks.
-Dominic
Solved! Go to Solution.
- Labels:
-
Enterprise Release Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 11:54 AM
Hey Dominic,
It's because your oldValue never gets changed to your newValue after the first confirm popup appears. Where are you setting oldValue and newValue? Since you're using oldValue for another function I would create a new variable outside of the onChange function and call it "oldState" which gets the initial state of the task (or you can set the value in the onLoad function). Then in the onChange function update the variable once it's inside your confirm code.
Something like this:
var oldState = g_form.getValue('state');
function onChange() {
var newState = g_form.getValue('state');
//other code
if (newState == 3 && aUC >1 && oldState != newState)
oldState = newState;
// confirm code
}
//other code
}
Let me know if this helps.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 11:54 AM
Hey Dominic,
It's because your oldValue never gets changed to your newValue after the first confirm popup appears. Where are you setting oldValue and newValue? Since you're using oldValue for another function I would create a new variable outside of the onChange function and call it "oldState" which gets the initial state of the task (or you can set the value in the onLoad function). Then in the onChange function update the variable once it's inside your confirm code.
Something like this:
var oldState = g_form.getValue('state');
function onChange() {
var newState = g_form.getValue('state');
//other code
if (newState == 3 && aUC >1 && oldState != newState)
oldState = newState;
// confirm code
}
//other code
}
Let me know if this helps.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 01:38 PM
Sir,
You are a Scholar and a Genius.
Thank you very much for the logic of approach, it's changed my world.lol
Thanks again.
-Dominic
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 01:52 PM
Haha thanks. I edited my previous comment because there was an error. I changed "var oldState = newState" to "oldState = newState". This will ensure it changes the correct variable and doesn't make a local copy of that variable within the function.