Need help with dialog box on a catalog item.

jd3737
Tera Contributor

Hello,

I'm trying to put a dialog box on a catalog item.   I want it to inform the user that they need to attach a form to the catalog item before they can proceed.   If the user clicks 'ok', it should load the catalog item.   If they hit 'cancel' it should redirect them to the Service Catalog.

Right now, hitting 'ok' works fine, but trying to redirect to the catalog isn't working.   When the user hits 'cancel' in I.E.11, it closes the tab and opens a new one at the service catalog.   However, in Firefox, it just loads a new tab at the service catalog, but loads the catalog item in the original tab.   Below is the code I'm using for the Catalog Client Script.   Any and all help would be greatly appreciated!

function onLoad (control, oldValue, newValue, isLoading, isTemplate) {

                           

                            if (isLoading || newValue == '') {

                                                          return;

                            }

                           

                            //var portalURL = getTopWindow().location.toString();

                           

                            var con = confirm("You must fill out and attach the Move form to complete your request.\nOnce you download the Move document, you can press Home at the top of the screen to leave this form.");

                           

                            if(con == false) {

                                                          window.top.close();

                                                          //window.open(portalURL);

                                                          window.open('https://stateofohiodev.service-now.com/ess/home');

                            }

}

1 ACCEPTED SOLUTION

frankh_
Giga Expert

I always seem to have trouble with window statements in server side scripts - can you try this:



window.open('https://stateofohiodev.service-now.com/ess/home', _self);


View solution in original post

3 REPLIES 3

frankh_
Giga Expert

have you tried window.location.assign() as opposed to window.open - seems to me window.open is supposed to open a new tab / window?


jd3737
Tera Contributor

function onLoad (control, oldValue, newValue, isLoading, isTemplate) {


                           


                            if (isLoading || newValue == '') {


                                                          return;


                            }


                           


                            //var portalURL = getTopWindow().location.toString();


                           


                            var con = confirm("You must fill out and attach the Move form to complete your request.\nOnce you download the Move document, you can press Home at the top of the screen to leave this form.");


                           


                            if(con == false) {


                                                          window.top.close();


                                                          //window.open(portalURL);


                                                          window.location.assign('https://stateofohiodev.service-now.com/ess/home');


                            }


}



Is this the correct placement of that code?   I tried that and it didn't load the form, but it also stayed on that page.


frankh_
Giga Expert

I always seem to have trouble with window statements in server side scripts - can you try this:



window.open('https://stateofohiodev.service-now.com/ess/home', _self);