Redirecting to the same page on click of Ui action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2022 11:20 PM
Hello Team,
I have written the below code to show the Confirm message based on Assignment group the message is showing fine for both if & else conditions in client side but when it takes if condition it's showing the confirm message and when tasks are in open state it's showing error message and re directing to a different page , how can we re direct it to the same job page after showing the error message.
Please find code below:
function sendReview() {
if (g_form.getValue("assignment_group") == 'b1d34f4b1b626010988ceac7b04bcbba') {
gsftSubmit(null, g_form.getFormElement(), 'sendreview_tax');
} else {
var answer = confirm("Test confirm box");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'sendreview_tax');
} else {
return false;
}
}
}
if (typeof window == 'undefined')
sendforReviewButton();
function sendforReviewButton() {
var audTask = new GlideAggregate('x_snc_coe_audit_task');
audTask.addAggregate('COUNT');
audTask.addEncodedQuery('statusNOT IN-5,3,4,8,9^audit_job=' + current.sys_id);
audTask.query();
audTask.next();
if (audTask.getAggregate('COUNT') > 0) {
gs.addErrorMessage('This action cannot be completed since there are open tasks for this Job');
current.setAbortAction(true);
}
else {
current.state = AuditGlobals.jobState.REVIEW;
current.update();
if (typeof window == 'undefined') {
action.setRedirectURL(current);
}
}
}
Please help me with the required inputs here it would be really helpful.
Thanks,
Ram
- Labels:
-
Problem Management
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2022 02:27 AM
Hi,
update as this
function sendReview() {
if (g_form.getValue("assignment_group") == 'b1d34f4b1b626010988ceac7b04bcbba') {
gsftSubmit(null, g_form.getFormElement(), 'sendreview_tax');
} else {
var answer = confirm("Test confirm box");
if (answer == true) {
gsftSubmit(null, g_form.getFormElement(), 'sendreview_tax');
} else {
return false; // this will keep user on same form
}
}
}
if (typeof window == 'undefined')
sendforReviewButton();
function sendforReviewButton() {
var audTask = new GlideAggregate('x_snc_coe_audit_task');
audTask.addAggregate('COUNT');
audTask.addEncodedQuery('statusNOT IN-5,3,4,8,9^audit_job=' + current.sys_id);
audTask.query();
audTask.next();
if (audTask.getAggregate('COUNT') > 0) {
gs.addErrorMessage('This action cannot be completed since there are open tasks for this Job');
current.setAbortAction(true);
action.setRedirectURL(current);
}
else {
current.state = AuditGlobals.jobState.REVIEW;
current.update();
if (typeof window == 'undefined') {
action.setRedirectURL(current);
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader