Reference Qualifier is not picking value in record producer

Aditya Kumar
Kilo Guru

hello Experts!

need help on advanced reference qualifier

scenario :- I've two variables in normal change record producer "requested for" "service offering", 

service offering is dependent upon requested for service offering shows the serivces subscribed by requested for

 

i've written a reference qualifier it is working fine connected with service offering field but its not picking the 

requested for value, when I hard code requested by its worked fine but its not picking it on its own

 

Record Producer

rec.png

 

reference qualifier

ref qual.png

 

Script include

 

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

    getOfferings: function(USerString) {
        //requested for's company
        var grZero = new GlideRecord('sys_user');
        grZero.addQuery('sys_id', current.u_requested_for);
        grZero.query();
        if (grZero.next()) {
            var company = grZero.company;
            var requestedFor = grOne.sys_id;
        }
        //company
        var grOne = new GlideRecord('service_subscribe_company');
        grOne.addQuery('core_company', company);
        grOne.query();
        if (grOne.next()) {
            serviceOferrings = grOne.service_offering + ',';
        }

        //group
        var grTwo = new GlideRecord('sys_user_grmember');
        grTwo.addQuery('user', requestedFor);
        grTwo.query();
        while (grTwo.next()) {
            var grThree = new GlideRecord('service_subscribe_sys_user_grp');
            grThree.addQuery('sys_user_group', grTwo.group);
            grThree.query();
            while (grThree.next()) {
                serviceOferrings = serviceOferrings + ',' + grThree.service_offering;
            }
        }
        return 'sys_idIN' + serviceOferrings;
    },
    type: 'cd_serviceOffering_re_qual'
});

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hi @Aditya Kumar ,

As far I understand, you are not passing any parameter within the function for to be able to be fetched in the script include. Could you try passing the parameter in the reference qualifier as:

javascript: new cd_serviceOffering_re_qual.getOfferings(current.variables.requested_for);

 

current doesn't essentially work in script include, for more details refer to below doc:

https://snprotips.com/blog/2019/12/18/can-script-includes-use-the-current-variable

 

Best Regards
Aman Kumar

View solution in original post

8 REPLIES 8

Mike_R
Kilo Patron
Kilo Patron

In your reference qualifier, where you are calling the getOffering function, you need to pass in your parameter USerString. Also in your addQuery, your need to replace current.u_requested_for with USerString

check Userstring is not holding anything from ref qual in service offering variable 

i've changed that still its not working

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

    getOfferings: function(USerString) {
        //requested for's company
        var grZero = new GlideRecord('sys_user');
        grZero.addQuery('sys_id', USerString);
        grZero.query();
        if (grZero.next()) {
            var company = grZero.company;
            var requestedFor = grOne.sys_id;
        }
        //company
        var grOne = new GlideRecord('service_subscribe_company');
        grOne.addQuery('core_company', company);
        grOne.query();
        if (grOne.next()) {
            serviceOferrings = grOne.service_offering + ',';
        }

        //group
        var grTwo = new GlideRecord('sys_user_grmember');
        grTwo.addQuery('user', requestedFor);
        grTwo.query();
        while (grTwo.next()) {
            var grThree = new GlideRecord('service_subscribe_sys_user_grp');
            grThree.addQuery('sys_user_group', grTwo.group);
            grThree.query();
            while (grThree.next()) {
                serviceOferrings = serviceOferrings + ',' + grThree.service_offering;
            }
        }
        return 'sys_idIN' + serviceOferrings;
    },
    type: 'cd_serviceOffering_re_qual'
});

Aman Kumar S
Kilo Patron

Hi @Aditya Kumar ,

As far I understand, you are not passing any parameter within the function for to be able to be fetched in the script include. Could you try passing the parameter in the reference qualifier as:

javascript: new cd_serviceOffering_re_qual.getOfferings(current.variables.requested_for);

 

current doesn't essentially work in script include, for more details refer to below doc:

https://snprotips.com/blog/2019/12/18/can-script-includes-use-the-current-variable

 

Best Regards
Aman Kumar

no sir still its not working, current works in script include with ref qual in normal incident or change form 

AdityaKumar_0-1668497292407.png