UI Action , script include parameters are not getting added

mrunalnikhi
Tera Contributor
// UI Action script part
function moveOrder() {

    var keys = g_list.getChecked();
    var arraykey = keys.split(',');
    if (keys == '') {
        var msg = new GwtMessage().getMessage('There are no rows selected');
        alert(msg);
        return;
    } else if (arraykey.length > 1) {
        var multipleselectmsg = new GwtMessage().getMessage('Move cannot be applied on multiple services, please select only one service');
        alert(multipleselectmsg);
        return;
    }
 
 var gacheckInActive = new GlideAjax('sn_ind_tmt_orm.CheckInactiveServices');
    gacheckInActive.addParam('sysparm_name','hasInactiveServices');
    gacheckInActive.addParam('sysId2',keys);
	gs.info('Before gacheckInActive.getXMLAnswer()');
    gacheckInActive.getXMLAnswer(function(response) {
        gs.info('Response from gacheckInActive: ' + response);
        if (response == 'true') {
            alert('Action cannot be performed as for the selected product Id, one of the Service is not in Active state.');
            return;
        } else{
			alert('Action can be completed');
		}
    });
	gs.info('After gacheckInActive.getXMLAnswer()');
 }




Script Include:
var CheckInactiveServices= Class.create();
CheckInactiveServices.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    hasInactiveServices: function() {
        var sysId = this.getParameter('sysId2');
        //gs.info('sysId: ' + sysId);

        var gr = new GlideRecord('sn_ind_tmt_orm_c360_products'); // Replace with your actual service table name
        if (gr.get(sysId)) {
            var prodId = gr.u_service_id;
            gs.info('prodId: ' + prodId);

            var ga = new GlideRecord('sn_ind_tmt_orm_c360_products'); // Replace with your actual service table name
            ga.addQuery('u_service_id', prodId);
            ga.addQuery('u_service_state', '!=', 'Active');
            ga.query();

            //gs.info("Checking for inactive services for product ID: " + ga.hasNext());
            return ga.hasNext(); // Returns true if there are any non-active services
        }
        //return false; // Handle the case when the initial GlideRecord query fails
    },

    type: 'CheckInactiveServices'
});

I am trying to call response from script include to UI action 'Move', but it is not working. Task is : when record is selected ,  script include is supposed to check if product id in record has one or more inactive services, if yes it will return true and response will get called in UI action script, but it is not working? what could be the reason? FYI, client check box in UI action is selected also in script include it is made as client callable.

2 REPLIES 2

Najmuddin Mohd
Mega Sage

Hi @mrunalnikhi ,

The return values are boolean. Can you change them to string. 
if(ga.hasNext()){

retrun 'true';
}else{

retrun 'false';

}

Also, can you check using g_Form.addInfoMessage() in UI Action script, since it is a client script instead of using gs.addInfoMessage().

Next one could be, if the above did not help still, since you want user to select only one record, why not convert the Checkboxes into Select box and send value.

Hope this works.
Regards,
Najmuddin.

 

Tai Vu
Kilo Patron
Kilo Patron

Hi @mrunalnikhi 

Remove these lines with gs.info in your UI Action, it should do the trick.

gs.info('Before gacheckInActive.getXMLAnswer()');
gs.info('Response from gacheckInActive: ' + response);
gs.info('After gacheckInActive.getXMLAnswer()');

 

Cheers,

Tai Vu