- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 11:40 PM
Hi,
I am using the following script for UI action to cancel the case. This is working fine except one thing- despite setting the workflow to false, a notification is being sent. How can I stop notifications from being sent?
function confirmCancellation() {
var confirmation = confirm('Are you sure you want to cancel this case?');
if (confirmation) {
g_form.setValue('state', '7');
for (var i = 0; i < g_form.elements.length; i++) {
var el = g_form.elements[i];
var fieldName = el.fieldName;
g_form.setMandatory(fieldName, false);
}
g_form.setMandatory('close_notes', true);
gsftSubmit(null, g_form.getFormElement(), 'cancelCase');
current.setWorkflow(false);
}
}
if (typeof window == 'undefined') {
cancelThisCase();
}
function cancelThisCase() {
current.state = '7';
current.setWorkflow(false);
current.work_notes = 'Case cancelled by ' + gs.getUserName();
current.update();
action.setRedirectURL(current);
}
Please help me stopping the notification whenever this UI action is clicked.
Regards,
Amit
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 11:59 PM
Hi
Pls set onClick as confirmCancellation() and use the following script-
function confirmCancellation() {
var gm = new GlideModal('convertToLabel');
gm.setTitle('Reason For Cancelation');
gm.renderWithContent('<div style="padding:15px"><p>Please write the reason for canceling this case.</p><p><textarea id="taskCancellation" name= "cancellation" rows="2" cols="60"></textarea></p><div style="padding:5px;float:right"><button style="padding:5px;margin-right:10px" onclick="window.changeTaskAction(this.innerHTML,jQuery(\'#taskCancellation\').val())" class="btn btn-success">Don\'t Cancel</button><button style="padding:5px" class="btn btn-danger" onclick="window.changeTaskAction(this.innerHTML,jQuery(\'#taskCancellation\').val())">Cancel Case</button></div></div>');
window.changeTaskAction = function(thisButton, thisAction) {
gm.destroy();
if (thisButton == 'Cancel Case') {
var userInput = thisAction;
if (thisAction) {
g_form.setValue('state', '7');
g_form.setValue('close_notes', thisAction);
g_form.setValue('active', 'false');
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setMandatory(fields[x], false);
}
}
gsftSubmit(null, g_form.getFormElement(), 'cancelCase');
}
};
return false; //prevents the form from submitting when the dialog first loads
}
if (typeof window == 'undefined') {
cancelThisCase();
}
function cancelThisCase() {
current.state = '7';
//current.active = 'false';
current.closed_at = new GlideDateTime();
current.setWorkflow(false);
current.work_notes = 'Case cancelled by ' + gs.getUserName();
current.update();
action.setRedirectURL(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2022 11:49 PM
Hi Amit,
1) current.setWorkflow(false); should be before gsftSubmit
2) In function cancelThisCase() : you dont have setWorkflow(false) line before current.update()
Try making those changes.
Mark as correct and helpful if it solved your query.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 12:27 AM
Hi Sumanth,
Thanks for your reply.
Unfortunately, this too did not work.
Regards,
Amit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 12:52 AM
What is the notification regarding?
Is that being triggered due to this script?
And can you tell what are you trying to achieve with this ui action so that I can see if anything else can be changed.
Regards,
Sumanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2022 01:14 AM
Hi Sumanth,
With this UI Action, I want to cancel the case without sending cancel notification. That notification is sent when state changes to cancel. With this script, I am setting the state to cancel. So I am able to cancel the case but the unable to stop that cancel notification.
Regards,
Amit
