How to show related records in 'Cost Center' variable on basis of 'Location'

Kartik Magadum
Kilo Sage

Hello

I have the Location variable, referring to 'cmn_location', and also have a Related list on 'cmn_location' that is Cost Center and referring to 'u_m2m_cmn_location_cmn_costcntr'.

On Selection of Location, that filters the cost center and shows the record in to Cost Center variable.

Please refer below Script include and reference qualifier using on 'Cost Center' variable 

RQ:

 

javascript: new PopulateCostCenter().getCost(current.variables.location);

 

SI: 

Client Callable

 

getCost: function() {
        var costcenterlist = [];
        var locationIs = new GlideRecord('cmn_location');
        locationIs.addQuery('sys_id',current.sys_id);
        locationIs.query();
        if (locationIs.next()) {
            var costIs = new GlideRecord('u_m2m_cmn_location_cmn_costcntr');
            costIs.addQuery('u_location', locationIs.sys_id);
            costIs.query();
            while (costIs.next()) {
              costcenterlist.push(costIs.getUniqueValue());
            }
        }
      return 'sys_idIN' + costcenterlist;
    },

 

And it's working fine in background script:

KartikMagadum_0-1701964041723.png

But, its is not filtering the records. 

Any assistance in resolving the issue would be greatly appreciated. 

Thanks and Regards

Kartik Magadum

1 ACCEPTED SOLUTION

Kartik Magadum
Kilo Sage

Hello all
Done with requirement and without script include, I have added a below line in RQ for cost center

javascript:"u_location=" + current.variables.location

 

Refer attached doc: Reference qualifier 
Note: No space before : and after : 

 

Thank You

View solution in original post

3 REPLIES 3

Elijah Aromola
Mega Sage

In your script include getCost method you have no parameter setup. You are passing current.variables.location into the script include, but you need to specify the parameter in the method declaration.

 

getCost: function(location) {
        var costcenterlist = [];
        var locationIs = new GlideRecord('cmn_location');
        locationIs.addQuery('sys_id', location;
        locationIs.query();
        if (locationIs.next()) {
            var costIs = new GlideRecord('u_m2m_cmn_location_cmn_costcntr');
            costIs.addQuery('u_location', locationIs.sys_id);
            costIs.query();
            while (costIs.next()) {
              costcenterlist.push(costIs.getUniqueValue());
            }
        }
      return 'sys_idIN' + costcenterlist;
    },

Thank You, but still not working

Kartik Magadum
Kilo Sage

Hello all
Done with requirement and without script include, I have added a below line in RQ for cost center

javascript:"u_location=" + current.variables.location

 

Refer attached doc: Reference qualifier 
Note: No space before : and after : 

 

Thank You