Issue with UI Action Button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 12:00 AM
Hello All ,
we have an UI Action to cancel the case for one of Our custom form , when we click on this UI Action button it asks to enter cancel comments in the Cancel comments field , after entering if they save the record it is not working and not updating the record and staying on the previous changes only but after entering the comments and again if we click on the cancel button it is working as expected but this should not be good presentation , so when you click on update or save this work should be saved , below is the script in the UI action can you please check and suggest
@Ankur Bawiskar @Sandeep Rajput
function CancelCase() {
g_form.setValue('state', -808); // rejected
g_form.setDisplay('u_cancel_comments', true);
g_form.setMandatory('u_cancel_comments', true);
if (g_form.getValue('u_cancel_comments') == '') {
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'cancel_case'); //MUST call the 'Action name' set in this UI Action
}
// Server side code
if (typeof window == 'undefined')
CancelEnhServer();
function CancelEnhServer() {
current.state = -808;
current.approval = 'not_required';
var workflow = new global.Workflow();
workflow.cancel(current);
current.update();
new UIActionUtils2().approvalsNoLongerRequired(current.sys_id); // to cancel users approval requests
action.setRedirectURL(current);
gs.addInfoMessage('xyzCase has been cancelled.');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 05:16 AM
that's much better.
On click of UI action show UI page and there ask the user to enter comments and then use UI page processing script to add server side code or use GlideAjax from UI page client script and then write server side code there
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 06:11 AM
@Ankur Bawiskar , can I have some script or reference for this ankur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 06:23 AM
something like this but you will have to enhance the logic. remember to use processing script in UI page and add the server side code there
How to get pop up in ITSM Application
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 12:44 AM
Hello @Ankur Bawiskar ,
I have Utilised OOB UI Page and called that into UI Action but it is not working can you please review and suggest if any Changes required
UI Page :
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:dialog_notes_ok_cancel
dialog_id="Finance_confirm_cancel"
textarea_id="Finance_cancel_confirm_reason_text"
textarea_label="${gs.getMessage('Cancellation Reason ')}"
textarea_label_title="${gs.getMessage('A reason is required to cancel this Finance')}"
textarea_name="Finance_cancel_confirm_reason_text"
textarea_onkeyup="enableButton()"
textarea_onchange="enableButton()"
textarea_style="height:auto; width: 100%; resize: vertical;"
textarea_title="${gs.getMessage('Enter the reason here')}"
ok=""
ok_action="cancelFinance"
ok_id="Finance_confirm_ok_btn"
ok_title="${gs.getMessage('Cancel Finance request')}"
ok_type="button"
ok_style_class="btn btn-primary disabled"
cancel_title="${gs.getMessage('Close the dialog')}"
/>
</j:jelly>
Client Script :
function cancelFinance() {
var textArea = $("Finance_cancel_confirm_reason_text");
if (textArea)
moveToCancel(textArea.value.trim());
}
(function() {
$("Finance_cancel_confirm_reason_text").focus();
})();
UI Action :