- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2015 03:29 PM
I have an onChange client script that runs when an incident is resolved the client script will pop up a dialog box for the user. When I resolve the incident from selecting the resolved state and save the incident I only receive one popup from my CS. But when i resolve the incident from my UI action (resolve incident) I receive 2 back to back popups. If i comment line 15 out I do not receive the popup BUT the incident does not save after the CS popup closes can someone help me out on why I might be seeing two popups when using the UI Action?
If i comment line 15 out I do receive the popup BUT the incident does not save after the CS popup closes can someone help me out on why I might be seeing two popups when using the UI Action?
function resolveIncident(){
//Set the 'Incident state' and 'State' values to 'Resolved', and display mandatory fields
g_form.setValue('incident_state', 6);
g_form.setValue('state', 6);
if (g_form.getValue('comments') == '') {
//Remove any existing field message, set comments mandatory, and show a new field message
try {g_form.hideFieldMsg('comments');} catch(e) {}
g_form.setMandatory('comments', true);
g_form.showFieldMsg('comments','Comments are required when resolving an Incident','error');
return false; //Abort submission
}
//Call the UI Action and skip the 'onclick' function
gsftSubmit(null, g_form.getFormElement(), 'resolve_incident'); //MUST call the 'Action name' set in this UI Action
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
serverResolve();
function serverResolve(){
current.incident_state = 6;
current.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2015 11:09 PM
Hi Sean, I'm appears to me that you're getting two alerts because you're setting both incident_state and state. You may have some code in your instance which is keeping these in sync and so then your onChange (which i assumed is for either state or incident_state) is then getting executed twice. Try setting only one, but not the two
You can start by trying to set only the state one. Meaning, comment out line 03 of your UI action. If that doesn't work then you can try keeping line 03 and commenting out line 04.
Please keep me posted how it goes, i'm really curious if this is the answer to your mystery
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2015 05:17 PM
Hi Sean,
Yeah, it's definitely weird. One thing you can do, if you're in a modern browser, is to add the "debugger" keyword to your script, right before the confirm:
if (newValue == 6 && newValue != oldValue && reassignment == 0 && tier == 'true' && (isItil || isItiladm || isAdm)&& (open == assigned || type=='self-service') && fTime == 'false' ){
debugger;
var answer = confirm('Select OK for First Contact Resolution or select Cancel if this is not a First Contact Resolution.');
if (answer == true){
Then, keep your developer tools open, navigate to the page, and trigger the behavior. You should be able to go through the callstack twice- once before each confirm dialog opens. Going through the stack should give you an idea of what is triggering the onChange script a second time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2015 11:09 PM
Hi Sean, I'm appears to me that you're getting two alerts because you're setting both incident_state and state. You may have some code in your instance which is keeping these in sync and so then your onChange (which i assumed is for either state or incident_state) is then getting executed twice. Try setting only one, but not the two
You can start by trying to set only the state one. Meaning, comment out line 03 of your UI action. If that doesn't work then you can try keeping line 03 and commenting out line 04.
Please keep me posted how it goes, i'm really curious if this is the answer to your mystery
Thanks,
Berny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2015 08:36 AM
It looks like this sets the state to resolved in line 3 and then checks to see if the comments are filled out before the submit. Then again in line 24 it sets the state again when the form is actually submitted. I am going to run through some more tests but commenting out one of these works. If i comment out line 4 my CS (since it runs on change) wont run until the comments are filled in and the user clicks resolve then (BP) Close Mandatory on Close or Resolve onSubmit CS runs and makes more fields mandatory close code close notes etc. thanks !