- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 07:32 AM
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
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 11:19 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 09:05 AM
I see the error on the browser console. It only happens on the Service Portal though.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 09:13 AM
Oh yeh, service portal won't allow glidemodal or glidedialogwindow. Sorry didn't catch that you were using SP.
i need to remember the code for displaying a modal on the portal. Onload script and glidemodal approach works fine in OOB views, but will need a diff approach for portal...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 08:57 AM
I have never used this in an onSubmit client script, why don't you move this code in an onLoad client script on whatever table shows up when the record is created.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 09:01 AM
Lol, was thinking the exact same thing. See above ^. I agree that the modal won't work properly in an onsubmit script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-04-2017 09:24 AM
Thanks guys for your replies - much appreciated!
I'm a novice to ServiceNow and learning by tinkering the existing code without a proper understanding of the system so please bear with me We are currently using the Service Catalogue in the back-end system (not sure if that's what it's called?) for all users but in the process of fixing bugs in SP with the hope of rolling out to users soon.
The record producer in question works fine in the back-end system's catalogue and what it does is that when a user submits a form a new page loads with some information to proceed with their query. This information is residing on UI pages. What I want to achieve with the SP though is that when a user submits the form they see a modal dialog with the same information as the back-end system.