Reference qualifier

users00024520
Tera Contributor

I need to make this filter, I have "Defined by Supplier" field and Assignment Group field.

The assignment group field has a company field (provider-defined)

When selecting the supplier, the assignment group field only shows me that they are associated with the supplier


It must be a reference qualifier.

 

Samuel9_1-1694648041905.png

 

7 REPLIES 7

OK, so the list collector is storing the sys_id of each CONTRACT record selected.  Vendor is just another field on that table, but is not meant to be the display value for that table.  I would recommend either changing the table this list field references to the core_company table with the reference qualifier vendor=true, or if you really must abuse the ast_contract table in this way for some reason you'll need to change the reference qualifier on assignment group to call a Script Include, passing in the value of u_slx_proveedor_definido.  The Script Include will do a GlideRecord query on the ast_contract table and return the record(s) of the selected contract(s).  From there you can then build an array of the Vendor on each contract record returned by the GlideRecord query.  Since Vendor is a reference field this will be sys_id(s).  Then you would do another GlideRecord query on the sys_user_group table with the addQuery line ('u_slx_proveedor', 'IN', venArr.join(',')) where venArr is the name of the array you pushed the contract vendor sys_ids into.  Push each group sys_id into another array, then return that back to the reference qualifier by ending the Script include with return 'sys_idIN' + grpArr.join(',');    

 

Another option could be to change the list field to a reference type, if you only need to select one vendor (contract).  Then the reference qualifier on assignment group with the dot-walking might work.

Dharmaraj5
Tera Contributor

Hello @users00024520 ,

 

You can achieve this requirement by using reference qualifier and script include , You have call script include using reference qualifier. Kindly try the following code.

 

Reference Qualifier : javascript: new GetVendor(). getdetails(current. u_slx_proveedor_definido)

Script Include:
Name : GetVendor
 Script : 
var GetVendor = Class.create();
GetVendor.prototype = {
    initialize: function() {},

    getdetails: function(sysid) {
        var temp = '';
        var gr = new GlideRecord('ast_contract');

        gr.addEncodedQuery('sys_idIN' + sysid);
        gr.query();
        while (gr.next()) {
            temp = temp + gr.vendor + ',';
        }
        var query = 'u_slx_proveedor.sys_idIN' + temp;
        return query;

    },
    type: 'GetVendor'
};

 

 

Find the screen print foe reference.

 

Dharmaraj5_0-1694804958368.png

Dharmaraj5_1-1694804989239.png

 

If my answer solves your issue please mark it as Helpful 👍 and Accepted✔️ based on impact.

Thanks & Regards,

Dharmaraj

 

Dharmaraj5
Tera Contributor

Hello @users00024520 ,

 

You can achieve this requirement by using reference qualifier and script include , You have call script include using reference qualifier. Kindly try the following code.

 

 

Reference Qualifier : javascript: new GetVendor(). getdetails(current. u_slx_proveedor_definido)

Script Include:
Name : GetVendor
 Script : 
var GetVendor = Class.create();
GetVendor.prototype = {
    initialize: function() {},

    getdetails: function(sysid) {
        var temp = '';
        var gr = new GlideRecord('ast_contract');

        gr.addEncodedQuery('sys_idIN' + sysid);
        gr.query();
        while (gr.next()) {
            temp = temp + gr.vendor + ',';
        }
        var query = 'u_slx_proveedor.sys_idIN' + temp;
        return query;

    },
    type: 'GetVendor'
};

 

 

 

Find the screen print foe reference.

 

Dharmaraj5_0-1694804958368.png

Dharmaraj5_1-1694804989239.png

 

If my answer solves your issue please mark it as Helpful 👍 and Accepted✔️ based on impact.

Thanks & Regards,

Dharmaraj