- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 12:15 AM
Hi All,
I am working on a Record Producer and it has a SpModal popup which has a simple function, if the user selects "Yes" it will take in the values the user has entered. If he clicks "No", it will clear out the fields.
It is working as expected but when I submit the form and then open it again to submit another request, the SpModal opens up 2 windows one according to the latest message and one with the older request.
Can you please help me out with this ?
Here is my Client Side Script:
api.controller = function($scope, $rootScope, spModal) {
var c = this;
$scope.page.g_form.setVisible("Note", false);
$scope.msg = '';
$scope.onLoad = function() {
c.server.update().then(function(res) {
$rootScope.$on("field.change", function(evt, parms) {
if (parms.field.name == 'u_service') //onChange condition for business_service
{
if ($scope.page.g_form.getValue('business_service') != '') {
$scope.CheckCat();
}
}
});
});
$scope.CheckCat = function() {
c.server.get({
action: 'check_cat',
category_sys_id: $scope.page.g_form.getValue('business_service')
}).then(function(response) {
var submit = response.data.Submit;
var msg = response.data.HTMLmsg;
var service = $scope.page.g_form.getDisplayValue('u_service'); //To get the value of "Service" and "Category"
var category = $scope.page.g_form.getDisplayValue('business_service');
if (submit == 'false') {
$scope.msg = response.data.HTMLmsg;
$scope.page.g_form.setLabelOf('Note', msg);
$scope.page.g_form.setVisible("Note", true);
$('button[name="submit"]').attr("disabled", true); //To disable the submit button
} else {
var message2 = "You are raising a ticket on " + "<b>" + category + "</b>" + " for " + "<b>" + service + "</b>" + ". If it is Correct, Click on " + "<b>Yes</b>" + " to confirm else click on " + "<b>No</b>" + " to scroll the list again "; // For the default message
$scope.msg = response.data.HTMLmsg;
if ($scope.msg != "." || $scope.msg != "") {
$scope.page.g_form.setLabelOf('Note', msg);
$scope.page.g_form.setVisible("Note", true);
} else {
$scope.page.g_form.setVisible("Note", false);
}
spModal.open({
title: 'Do you agree?',
message: message2,
buttons: [{
label: '✘ ${No}',
cancel: true
},
{
label: '✔ ${Yes}',
primary: true
}
]
}).then(function() {
$scope.page.g_form.getValue('u_service');
$scope.page.g_form.getValue('business_service');
}, function() {
$scope.page.g_form.setValue('business_service', '');
$scope.page.g_form.setValue('u_service', '');
$scope.page.g_form.setValue('short_description', '');
$scope.page.g_form.setValue('description', '');
});
$('button[name="submit"]').attr("disabled", false); //To enable the submit button
}
});
};
};
};
I have searched the community a lot related to anything with this but could not find much.
Any help would be much appreciated.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 12:34 AM - edited 11-15-2023 12:37 AM
Hi @Ankur Bawiskar,
I found the solution in a post .
I just added $uibModalStack.dismissAll(); before opening my SpModal and it resolved my issue.
Thank you so much for the help.
@Ankur Bawiskar and @JonathanJacob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 12:29 AM
you are using widget and including it in custom type variable?
please share some screenshots.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 12:38 AM
Yes @Ankur Bawiskar , exactly.
I am attaching the screenshot of the custom variable here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 02:31 AM
are you not closing the modal once user clicks the button?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 08:38 PM
@Ankur Bawiskar
Yes that is the problem, let me show you the portal side.
This my SpModal with the message. Now I click Yes and the SpModal closses and I raise the incident. (This is a Record Producer)
Now I go back to a fresh Record with different category, but now I get 2 SpModal popups.
One with the new Value and one with the older Value.
Attaching the screenshot below.
After Clicking Yes or No
I get the same old Pop up which I have not even selected: