Pass the values from client script to widget using spModal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
14m ago
Hi,
I’m currently working on a use case where I need to display a popup message after submitting a Service Catalog form. To achieve this, I created a custom widget and added an onSubmit Catalog Client Script to invoke the widget.
Below is the catalog client script I’m using:
function onSubmit() {
// Delay needed so RITM gets created first
setTimeout(function() {
spModal.open({
widget: 'ritm_onsubmit_alert', // ✅ your widget ID
size: 'lg',
widgetInput: {
ritm: "RITM-Test-Num", //data.ritm,
submitted: "19/05/2026" //data.submitted
},
buttons: [] // remove default buttons
});
}, 2500); // ✅ IMPORTANT delay
return false;
}
As shown above, the popup appears after clicking the Submit button.
Issue:
I want to dynamically pass values such as the RITM number and submission date to the widget. However, I’m facing issues while passing these values.
I’ve tried multiple approaches, but none of them worked.
I’m also sharing both the Server Script and Client Script of the widget for reference.
Server-Side Script from widget:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
if (input.userInput) {
gs.addErrorMessage("Input is working...");
data.ritm = input.ritm || "Loading...";
data.submitted = input.submitted || new GlideDateTime().getDisplayValue();
}else{
gs.addErrorMessage("Input is not working...")
}
})();
Client-Side Script from widget:
api.controller = function($scope, spModalInstance) {
/* widget controller */
var c = this;
c.close = function() {
spModalInstance.close();
};
};
Could someone please help me resolve this issue? Any guidance would be greatly appreciated.
Thanks in advance!
