The CreatorCon Call for Content is officially open! Get started here.

Script Include returning null?

Sid_Takali
Kilo Patron

Hi all, 

The following Script returning null value. I need consumer sys_id. Thanks in advance 

Script Include - 

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

    ConsumerS: function() {
        var g = this.getParameter('syparm_cons');
        var CONsumer = '';
        gs.info("Include::::" + g);
        var gr1 = new GlideRecord('sn_customerservice_product_service_support');
        gr1.addQuery('sys_id', g);
        gr1.query();
        if (gr1.next()) {
            CONsumer = gr1.consumer;
        }
        return CONsumer;

 },

 

Client Script - 

        var ans = '';
        var con = g_form.getValue('parent');

        var ga1 = new GlideAjax('sn_customerservice.customerPhones');
        ga1.addParam('syparm_name', 'ConsumerS');
        ga1.addParam('syparm_cons', con);
        ga1.getXML(HelloWorld);

        function HelloWorld(response) {
            ans = response.responseXML.documentElement.getAttribute("answer");
            alert(ans);
        }

10 REPLIES 10

Abhijit4
Mega Sage

Hey Aman,

Yes, make sense.

@Siddharam if you need more field from that record then you can use getReference, if you need only one value then its better to go with GlideAjax.

 

By marking my response as correct or helpful, you contribute to helping future readers with similar issues.
Regards,
Abhijit
ServiceNow MVP