close spmodal using widget button in widget
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2023 02:18 AM
c.onWidget = function(widgetId, request){
spModal.open({
title: 'Check-in',
widget: widgetId,
buttons: [],
widgetInput: {table: 'x_138031_myTable',
sys_id: request.id,
}
}).then(function(){
console.log('widget dismissed');
});
Below is the code which i have written in client side script of widget. Basically i am using spModal to show another widget as pop up on current widget. The same pop i am trying to close once submit butto is clicked. but as of now its not getting closed can you please modify the below code
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-15-2023 08:10 AM
Hi @avinash kirde1 ,
To close the spModal
from your widget, you can use the dismiss
method. Here's how you can modify your code:
c.onWidget = function(widgetId, request) {
var modalInstance;
spModal.open({
title: 'Check-in',
widget: widgetId,
buttons: [],
widgetInput: {
table: 'x_138031_myTable',
sys_id: request.id,
},
}).then(function(instance) {
modalInstance = instance; // store the modal instance for later use
console.log('widget dismissed');
});
// Assume you have a button with id 'submitBtn' in your widget
$('#' + widgetId).on('click', '#submitBtn', function() {
// Perform your submit logic here
// Close the modal when done
if (modalInstance) {
modalInstance.dismiss();
}
});
};
Also, refer similar thread - https://www.servicenow.com/community/developer-forum/close-the-spmodal-from-embeded-widget/m-p/13716...
Thanks,
Ratnakar