How to display locations based on company in catalog

nagaklv
Tera Contributor

Hello Community,

I have two variables in catalog item 

1. Vendor - reference to core_company

2.locations - reference to cmn_location

So if i select company and it should be related locations in location reference

for example if select japan and it should be display only japan locations in locations reference variables

 

Can you please help me how to sort out this.

 

Thanks,

Nagesh klv

1 ACCEPTED SOLUTION

Hi,

You also need to add the following attribute

ref_qual_elements=vendor

Only then the selected vendor will be passed to the server and fetches the locations accordingly.

View solution in original post

11 REPLIES 11

Willem
Giga Sage
Giga Sage

Not sure what you want to do exactly? If you Select a Vendor that is in Japan, you want only locations that are in japan?

 

You can create a Script include as follows:

 

var getRecords = Class.create();
getRecords.prototype = {
    initialize: function () {
    },

    getCountry: function (vendor) {
        var gr = new GlideRecord('core_company');
        if (gr.get(vendor)) {
            return 'country=' + gr.getValue('country');
        } 
    },

    type: 'getRecords'
};

 

Then in the Reference qualifier of your Locations field use:

javascript: new getRecords().getCountry(current.variables.vendor_field);

 

Updated the code.

nagaklv
Tera Contributor

Sorry for the confusion

actually i want to display the locations based on company selection

if i select abc company i want display that company locationsv in location variable

In the locations field use the Advanced Reference qualifier:

Replace vendor_field with the name of your field that is referencing the company

javascript: 'company=' + current.variables.vendor_field;

 

You do not need the script include.