We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Script Include Returning Null in answer

ManishS14752344
Tera Contributor

Hi, 

So, I am using this catalog client script

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || !newValue) return;

    var ga = new GlideAjax('AccountSTOChecker');
    ga.addParam('sysparm_name', 'checkStoreOrder');
    ga.addParam('sysparm_account_id', newValue);

    ga.getXMLAnswer(function (answer) {

        if (answer === null) {
            console.error('GlideAjax returned NULL - Script Include not reachable');
            return;
        }

        console.log('Account STO Type stored:', answer);

        sessionStorage.setItem('accountSTOType', answer);

        if (answer === 'true') {
            g_form.addInfoMessage('STO Account - attachment required');
        }
    });
}


With this Script Include

var AccountSTOChecker = Class.create();
AccountSTOChecker.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    checkStoreOrder: function () {
        var accountId = this.getParameter('sysparm_account_id');

        if (!accountId)
            return 'false';

        var acc = new GlideRecord('customer_account');
        if (!acc.get(accountId))
            return 'false';

        var type = acc.getValue('u_so_sto');

        if (type == '2') {
            return 'true';
        }

        return 'false';
    },

    type: 'AccountSTOChecker'
});

But The answer I am getting is null.

The Script Include is client callable so I am unable to figure it out.

Thanks in advanced.

1 REPLY 1

Vijaya_Mnpram
Kilo Sage

@ManishS14752344 You can put some gs.info statements at various stages of the server script and check the logs to see if the logic is flowing at each stage.

All I am suggesting is, instead of looking for final output, you can put log statements at every stage and see.