- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 05:46 AM
hi can anyone help me with the requirment for
in the purchase order form there is a ui action button called as cancel, i want to display an alert pop up after user clicks on cancel and ui action in the message stating as do you want to cancel it? comform ui action button in message, after user clicks on comform then status should get cancelled.
Below is the code
cancelPO(current);
function cancelPO(grRecord) {
var gr = new GlideRecord('proc_po_item');
gr.addQuery('purchase_order', grRecord.getUniqueValue());
gr.query();
while (gr.next()) {
gr.status = 'canceled';
gs.addInfoMessage("Please confirm that you want to cancel this PO request");
gr.update();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 06:29 AM - edited 06-28-2023 06:30 AM
Hi @raj765_32
You need client UI Action for this:
In UI Action :
Client checkbox should be true
Action name : give any name here,this will be used in gsftsubmit in the script.
onclick:onClick();
code://modify field names accordingly
function onClick() {
var usrResponse = confirm(getMessage("Pease confirm that you want to cancel "));
if (usrResponse == true)
gsftSubmit(null, g_form.getFormElement(), 'cancel_case'); //Add the action name here
else
return false;
}
if (typeof window == 'undefined')
cancelCase();
function cancelCase() {
var gr = new GlideRecord('xyz');
gr.addQuery('purchase_order', current.sys_id);
gr.query();
while (gr.next()) {
gr.status = 'canceled';
gr.update();
} action.setRedirectURL(current);
}
Refer articles below
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0657198
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-28-2023 06:29 AM - edited 06-28-2023 06:30 AM
Hi @raj765_32
You need client UI Action for this:
In UI Action :
Client checkbox should be true
Action name : give any name here,this will be used in gsftsubmit in the script.
onclick:onClick();
code://modify field names accordingly
function onClick() {
var usrResponse = confirm(getMessage("Pease confirm that you want to cancel "));
if (usrResponse == true)
gsftSubmit(null, g_form.getFormElement(), 'cancel_case'); //Add the action name here
else
return false;
}
if (typeof window == 'undefined')
cancelCase();
function cancelCase() {
var gr = new GlideRecord('xyz');
gr.addQuery('purchase_order', current.sys_id);
gr.query();
while (gr.next()) {
gr.status = 'canceled';
gr.update();
} action.setRedirectURL(current);
}
Refer articles below
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0657198
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP