Popup form when we click Order Now

abhishekte
Mega Expert

Hi Experts, When user click on order now,I need to show a POP up containing text with two checkboxes as one of the variable like: Please confirm by ticking the box that a) the Contact you entered is correct b) you have changed the Contact in order from The boolean value of the tick box should also be stored. If the box was ticked, store TRUE. If the box wasn't ticked, the button "OK" cannot be selected. If "OK" gets selected, the request is created. If "Cancel" gets selected, the pop-up closes and the user is taken to the previous screen. Any idea how we can achieve the same in service catalog.

1 ACCEPTED SOLUTION

Adding this piece of code on UI page of OK button will submit the catalog item:


// This will submit the order


gel("order_now").onclick = "";


var item_guid = gel("sysparm_item_guid");


if (item_guid) {


    item_guid = item_guid.value;


}


g_cart.order(gel("sysparm_id").value, getQuantity(), item_guid);


  }




Thanks to SN guru form for the same.


View solution in original post

8 REPLIES 8

On the first question: You can simply disable the functionality to submit the form on the onSubmit by returning false after rendering the UI Page, but that would make necessary for you to submit the form on the UI Page once it gets destroyed.



On other words, your onSubmit script would be like:


    //Initialize and open the Dialog Window


    var dialog = new GlideDialogWindow("your_ui_page"); //Render the dialog containing the UI Page


    dialog.setTitle("Please confirm:"); //Set the dialog title


    dialog.setPreference("comments_text", comments_text); //Pass in comments for use in the dialog


    dialog.setPreference("short_text", short_text); //Pass in short description for use in the dialog


    dialog.render(); //Open the dialog




    return false;




And on the HTML on your UI Page you'll have on the buttons:


<g:dialog_button onclick="return onSubmit();" name="ok_button" id="map_button">${gs.getMessage('OK')}</g:dialog_button>


<g:dialog_button onclick="cancel();" name="cancel_button" id="cancel_button">${gs.getMessage('Cancel')}</g:dialog_button>



and on the Script part, you'll have the functions:



function onSubmit() {


  // Question 2 here: You'll validade your HTML componente like:


  if (gel('id.of.html.field').value == '') {


          alert('You need to fill the info!');


          return false;


  }



  GlideDialogWindow.get().destroy();


  g_form.save();


}




function cancel() {


  GlideDialogWindow.get().destroy();


}


Hi,



By putting return false, and using Onsubmit again on UI page as mentioned above, I will not able to submit the order form automatically after filling the UI form.If I click again Order Now again I see the UI form again.Kindly let me know If I have done anything wrong.



I want the order the item after filling UI form and click OK on UI form.


Adding this piece of code on UI page of OK button will submit the catalog item:


// This will submit the order


gel("order_now").onclick = "";


var item_guid = gel("sysparm_item_guid");


if (item_guid) {


    item_guid = item_guid.value;


}


g_cart.order(gel("sysparm_id").value, getQuantity(), item_guid);


  }




Thanks to SN guru form for the same.


ntera4sho
Kilo Explorer

This works like a charm. Thanks