Create a popup box for a catalog item

Cupcake
Mega Guru

I have a catalog form that contains a field asking what type of member are you trying to Onboard, I want to create a confirmation popup box that says something like "Are you sure this is the type of member you want to onboard? ". I would like the confirmation pop up to be a Yes or No, and if No then reset that field back to the default of "none". I want the pop up to occur upon Submission of the form or is there a way to have it appear after one of the selections is made.

find_real_file.png

I know that I can use a confirm type of script like: confirm("Hello World"); Will pop up a window with "Hello World?" and a 'Ok' and 'Cancel' buttons.

Is that done thru the gs.addInfoMessage("Hello World"); Will put "Hello World" on the top of the screen

Please assist if you can and I will need some assistance with the javascript that may be required.

Thanks again.

Karen

1 ACCEPTED SOLUTION

joshua_bice
Giga Expert

onChange client script for the field in question. Here's the code:



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


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


                  return;


        }



        var con = confirm("Are you sure this is the type of member you want to onboard?");



        if(con == false)


                    control.value = oldValue; //This can also be simply an open and close apostrophe '' to bring it back to None.


}



That should do it for you.


View solution in original post

7 REPLIES 7

Nana5
Mega Guru

hi Karen,


For this requirement you need to go for glidedialogwindow.


Please follow the following steps:-



1.create one onChange client script and render that glidedialogwindow(it will call the UI Page) based on work force member type.


2. you have to create the uI page that should contain the confirmation message.



Please refer the below link.


Displaying a Custom Dialog - ServiceNow Wiki



Please let me know if u need any more input.



Thanks


Prakash Ranjan


Hi,



what about a jQuery component: http://jqueryui.com/dialog/#modal-confirmation



This should make it for you together with the onChange client script on that specific field with the code similar to following:



$("#dialog-confirm").dialog({


      resizable: false,


      height: 140,


      modal: true,


      buttons: {


              "Yes": function() {


                      $(this).dialog("close");


              },


              "No": function() {


                      // reset the value of the field here..


                      $(this).dialog("close");


              }


      }


});


joshua_bice
Giga Expert

onChange client script for the field in question. Here's the code:



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


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


                  return;


        }



        var con = confirm("Are you sure this is the type of member you want to onboard?");



        if(con == false)


                    control.value = oldValue; //This can also be simply an open and close apostrophe '' to bring it back to None.


}



That should do it for you.


Thank you again Joshua - this worked perfectly.