How to Query the Reference field by scripting?

Sudesh
Tera Contributor

In Catalog item, i have a variable with type Reference field to 'cmn_location' table, The variable is in Variable Set using in multiple catalog items. Specific to my catalog item i need to hide the certain locations  by Name ,while loading of catalog item. 

Reference Qualifier is not a Preferable solution as variable is  using in multiple catalog item

How can achieve this by scripting?

1 ACCEPTED SOLUTION

Anil Lande
Kilo Patron

Hi,

You can use advanced reference qualifier like below and make script include call.

javascript: new scriptIncludeName().myFunctionName(current.cat_item)

In script include check if it is your catalog item and return query as per your requirement.

var scriptIncludeName= Class.create();
scriptIncludeName.prototype = {
    initialize: function() {
    },
    myFunctionName: function(catItem) {
        if (catItem == '<sys_id of your catalog item>') {
            return 'nameNOT LIKEsouth';
        } else {
            return '';
        }
    },
    type: 'scriptIncludeName'
};

 

If it is your catalog item then return the encoded query else return nothing to show all records.

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

1 REPLY 1

Anil Lande
Kilo Patron

Hi,

You can use advanced reference qualifier like below and make script include call.

javascript: new scriptIncludeName().myFunctionName(current.cat_item)

In script include check if it is your catalog item and return query as per your requirement.

var scriptIncludeName= Class.create();
scriptIncludeName.prototype = {
    initialize: function() {
    },
    myFunctionName: function(catItem) {
        if (catItem == '<sys_id of your catalog item>') {
            return 'nameNOT LIKEsouth';
        } else {
            return '';
        }
    },
    type: 'scriptIncludeName'
};

 

If it is your catalog item then return the encoded query else return nothing to show all records.

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande