- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2025 10:53 AM
Hey guys!
I have a UI action button that I'm trying to fix, which is supposed to put an order in 'state' = 5 + 'decom_state' = 'closed_incomplete'.
This is what my Script Includes looks like:
var CancelOrderAJAX = Class.create();
CancelOrderAJAX.prototype = Object.extendsObject(AbstractAjaxProcessor, {
cancel: function() {
var sysId = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord('x_vgll_decom_decommission');
if (gr.get(sysId)) {
gr.state = 5;
gr.decom_state = 'closed_abandoned';
gr.update();
return 'OK';
}
return 'Fel: kunde inte hitta posten';
},
type: 'CancelOrderAJAX'
});
This is what my UI Action script looks like:
function cancelOrder() {
var ga = new GlideAjax('CancelOrderAJAX');
ga.addParam('sysparm_name', 'cancel');
ga.addParam('sysparm_sys_id', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
if (response === 'OK') {
g_form.clearModified(); // Rensar ändringsstatus
g_form.refresh(); // Uppdaterar formuläret utan att navigera bort
} else {
g_form.addErrorMessage('Kunde inte annullera beställningen: ' + response);
}
});
}
When I press on the button, nothing happens. What have I missed?
The Script Includes is in a specific scope called Decommission, could this be the issue?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2025 01:07 PM
Hi @ronro2 ,
At first look what looks wrong to me is, since the SI is in a specific scope application then you need to use the scope name as well while calling the GlideAjax in your UI action. Please modify the line as shown below and see if it works and if it does not then further troubleshooting can be done.
var ga = new GlideAjax('x_vgll_decom.CancelOrderAJAX');
If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2025 02:25 PM - edited 05-17-2025 03:42 PM
Hi ronro2,
In addition to the modification that Animesh suggested....
var ga = new GlideAjax('x_vgll_decom.CancelOrderAJAX');
In your script include, change the name to CancelOrderAJAX (they should match)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2025 12:43 PM
Hi @ronro2 ,
you don't have to use the client side UI action for this
uncheck the client checkbox and use this shared script
current.state = 5;
current.decom_state = 'closed_abandoned';
current.update();
action.setRedirectURL(current)
if you still want to go with client and GlideAjax
g_form.clearModified() and g_form.refresh() are not a valid methods
g_form.clearModified(); // Rensar ändringsstatus g_form.refresh();
you can go with server side UI action with above shared script
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2025 01:07 PM
Hi @ronro2 ,
At first look what looks wrong to me is, since the SI is in a specific scope application then you need to use the scope name as well while calling the GlideAjax in your UI action. Please modify the line as shown below and see if it works and if it does not then further troubleshooting can be done.
var ga = new GlideAjax('x_vgll_decom.CancelOrderAJAX');
If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2025 02:25 PM - edited 05-17-2025 03:42 PM
Hi ronro2,
In addition to the modification that Animesh suggested....
var ga = new GlideAjax('x_vgll_decom.CancelOrderAJAX');
In your script include, change the name to CancelOrderAJAX (they should match)