- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on ‎06-20-2020 02:32 AM
Hi,
There might be situations where we would like to show a popup when submitting a service catalog.
This article gives one way of implementing a custom popup.
1. Create an onLoad Catalog client script as shown below.
- showAlertPlatform
- Will show a popup in the platform view. For the purpose of this article, I have used the existing OOB UI page - glide_confirm_standard to display as a popup. We can clone this and modify it according to our needs.
- showAlertServicePortal
- Will show a custom widget as a popup when submitting the catalog in service portal.
function onLoad() {
//g_user - GlideUser object
g_user.readyForSubmit = false;
g_user.showAlertPlatform = function(msg) {
var dialog = new GlideModal('glide_confirm_standard');
dialog.setPreference('warning', true);
dialog.setSize(450);
dialog.setTitle('Custom Title');
dialog.setPreference('title', msg);
dialog.setPreference('onPromptComplete', function() {
g_user.readyForSubmit = true;
saveProducer();
});
dialog.setPreference('onPromptCancel', undefined);
dialog.render();
};
g_user.showAlterServicePortal = function(msg) {
var shared = {};
shared.message = msg;
var popupOptions = {
title: 'Custom Title',
widget: 'custom-popup',
shared: shared,
footerStyle: {display:'none'}
};
var modalInstance = spModal.open(popupOptions).then(function() {
g_user.readyForSubmit = true;
g_form.submit();
});
};
}
2. Create an onSubmit catalog client script one for the platform and another for portal.
Let's name our script as - Custom popup - onSubmit - Portal, which will contain below code.
UI Type field should be set to - Mobile / Service Portal
function onSubmit() {
if (g_user.readyForSubmit) return true;
g_user.showAlterServicePortal('Message to show in the popup');
return false;
}
In case of platform view, lets name our script as - Custom popup - onSubmit - platform, which will contain below code.
UI Type field should be set to - Desktop.
function onSubmit() {
if (g_user.readyForSubmit) return true;
g_user.showAlertPlatform('Message to show in the popup');
return false;
}
3. The custom widget code will be as shown below. This is a simple widget which will show the message that is sent as part of the spModal popup options.
HTML:
<div>
<div class="row">
<div class="col-sm-12 col-md-12">
{{c.message}}
</div>
</div>
<div class="modal-footer">
<button type="submit" ng-click="$parent.$parent.buttonClicked($parent.$parent.options.buttons[1])" class="btn btn-primary pull-right m-l-sm">Submit</button>
<button type="button" ng-click="$parent.$parent.$dismiss()" class="btn btn-default pull-right">Cancel</button>
</div>
</div>
Client script:
function() {
/* widget controller */
var c = this;
var shared = c.widget.options.shared;
c.message = shared.message;
}
4. Screenshot - Platform
5. Screenshot - Portal
Thanks
- 15,565 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi Satya,
I have successfully reproduced above steps but i want print "i acknowledge text in new line", i tried all possible ways but i dont have any luck. can you please suggest me.
Thanks
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
satyach,
I am totally stumped why this isn't working as expected in Portal. This post was 2 years ago so maybe it needs modifications to the solution. Platform alert is working however the portal widget has a Title but does not have any text or buttons.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Yes I am also facing the same issue. The popup is coming in the portal but the message is empty only.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Make sure you fill out the ID field on the widget, otherwise it won't be found which is resulting in the above screenshot of no message or buttons.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
It's a great information....and its very helpful and useful.
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello All,
I have implemented the same functionality using the same above steps and I am able to get the buttons as well as message on the pop up on both the portal as well as desktop view. After Clicking on confirm button the requests gets submited successfully on the portal.
But when we click on "OK" button on the popup, when viewed from desktop view the request is not submited! If anyone has a solution please let me know.
Thank You in advance!!
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
i am trying to leverage this functionality but also pass variable values in the shared object, then reference those values in the server script for a query... see the following post:
does anyone know how to do this or have an alternate method?
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Satyanarayana CThank you for sharing this; it was really helpful in solving my requirement.