Client Callable Script Include in Scoped App Not Invoked from UI Action via GlideAjax

ronro2
Tera Contributor

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'

});

ronro2_2-1747504279699.png



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);
    }
  });
}

 

ronro2_0-1747504168960.png

 

ronro2_1-1747504214990.png



When I press on the button, nothing happens. What have I missed? 

ronro2_3-1747504377630.png


The Script Includes is in a specific scope called Decommission, could this be the issue? 

Thanks in advance!

 



2 ACCEPTED SOLUTIONS

Animesh Das2
Mega Sage

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

View solution in original post

Craig Gruwell
Mega Sage

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)

 

2025-05-17_17-20-15.jpg

 

 

View solution in original post

3 REPLIES 3

Chaitanya ILCR
Kilo Patron

Hi @ronro2 ,

you don't have to use the client side UI action for this

uncheck the client checkbox and use this shared script

 

ChaitanyaILCR_0-1747510742835.png

 

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

 

 

 

 

Animesh Das2
Mega Sage

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

Craig Gruwell
Mega Sage

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)

 

2025-05-17_17-20-15.jpg