Onsubmit client script

ThenmozhiA
Tera Contributor

Hi All,
This is for a service catalog, on submit, a popup message should display with yes and No buttons. On clicking yes it should be submitted, when No is clicked it should be redirected to a different item. Can you help with the script part?

4 REPLIES 4

Sandeep Rajput
Tera Patron
Tera Patron

@ThenmozhiA Please refer to this thread https://www.servicenow.com/community/developer-forum/confirm-box-using-client-script/m-p/1430048 to know how confirm box can be utilised in this case. 

 

Hope this helps.

seethapathy
Giga Guru
Hi @ThenmozhiA I tried you requirement in My PDI it is working fine for me, if this script is  helpful mark it as helpful
var msg =confirm("Add your message here");
   if(msg == true){
    return true;
   }
   else{
    return false;
   }

Thanks but i need the pop up message to have yes and No buttons, upon clicking yes it should redirect to  another link and upon No the request should be submitted.

Vaishnavi Lathk
Mega Sage
Mega Sage

You could use something along these lines..

https://community.servicenow.com/community?id=community_question&sys_id=57c4cbe9dbd8dbc01dcaf3231f96...

 

Sample Script:

function onSubmit() {

      var confirm = confirm("Did you submit form 104333?");

      if (confirm == false) {

              return false;

      }

}