Widget Client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2023 10:41 PM
\
Hi Experts,
Can someone please help me understand what is done in the below script in the function openModalResolve?
I know whats happening in the form, there is form button, on click of the button option there is small dialog box opens, where user can enter comments and submit. But I need help is understanding this piece of code. what is modalInstance , what is $uibModal, what is templateUrl?
api.controller = function($uibModal, $scope, spUtil) {
/* widget controller */
var c = this;
c.uiAction = function(action) {
c.data.action = action;
c.server.update().then(function() {
c.data.action = undefined;
//spUtil.addInfoMessage("Incident has been cancel", 3000);
});
c.modalInstance.close();
};
c.openModalResolve = function() {
if (c.data.showmodal) {
c.modalInstance = $uibModal.open({
templateUrl: 'modalTemplateCancelNew',
scope: $scope
});
} else {
c.modalInstance = $uibModal.open({
templateUrl: 'CancelactivecontractsourcingNew',
scope: $scope
});
c.data.user = {
value: '',
displayValue: ''
};
}
};
c.closeModal = function() {
c.modalInstance.close();
};
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2023 06:26 AM
c.modalInstance is the variable representation of the entire modal that is displayed by $uibModal so it's easier to call back to it and interact with it programmatically.
$uibModal is an angular method of creating a modal window. This can be used in Service Portals instead of the spModal modal API provided by ServiceNow which may be easier to work with. Depends on a persons familiarity with either and intended use.
templateUrl is a parameter passed to the modal that determines what exactly to load. This could be an angular ng-template included in the related list or something else embedded on the page through the HTML rendered.
- Angular ng-template example: Knowledge Article Content (kb-article-content) widget
- Embedded example: https://serviceportal.io/modal-windows-service-portal/
Here is a thread that has a lot more information about $uibModal: https://www.servicenow.com/community/developer-forum/how-to-use-uibmodal-in-service-portal/m-p/15897...