Open a modal after form submission

jonndoe
Kilo Contributor

Hi guys,

I was wondering if I could open a modal popup with some data in it after a record producer is submitted in Service Portal. I have this record producer that requires displaying some information to the users upon submitting a form and wonder if someone could shed some light on how to achieve this please?

Many thanks,

JD

1 ACCEPTED SOLUTION

here is an example onload client script I wrote that should work for either SP or OOB views. you can render direct content in the glidemodal like this code below. If you would rather use a ui page that is fine for the GM, but for the spModal, you would need to create a new SP widget to display it. this should give you the concept though. spModal is only available on Portal, so that is why we handle both cases in one script. Make sure you select UI Type = All in your client script.



function onLoad() {


    //Type appropriate comment here, and begin script below


  if (typeof spModal != 'undefined') {


      spModal.open({


          message: 'This is a test SP modal',


          title: 'Test SP Modal'


      });


  } else {


      var gm = new GlideModal();


      gm.setTitle('Test GM');


      gm.renderWithContent('This is a test GlideModal');


  }


}



This technically should work the same in a catalog onSubmit client script, but I still feel there will be an issue with redirects in the OOB view, though it actually may work fine in the SP because it is a single page app so doesn't do a true redirect after submission.


View solution in original post

29 REPLIES 29

karthik73
Mega Guru

Hi John,



You can open a modal with this script on the on submit client script, and display a UI page on the modal window with the contents you want to display



var gdw = new GlideDialogWindow(<ur UI page name>);


gdw.setTitle('<title of the modal window>');


gdw.setSize(650,3000);


gdw.render();


}


Thanks, Karthik for the swift reply - I will have a look at implementing this.



Cheers!


Do you need an Angular modal popup?? or you just want to render a popup page??


-Anurag

Hi Anurag,



An angular modal pop up would be ideal. I want to display a message depending on the option a user selects in the form so there are about five different messages in total. I have very little knowledge of ServiceNow and angular so struggling to put together this functionality.



Thanks,



JD