The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Reference qualifier with cilent script

AnnamalaiS
Tera Contributor

I have cost center field (select lookup with reference to cost center table) and project category field (selectbox with manually entered values).

 

Cost center based on project category.

 

Example: scent (project category) has 3 cost center. It should only visible instead of showing the whole list.

 

I need reference qualifier with client script for this.

 

26 REPLIES 26

Hi,
yes

Try below solution 

  • Create script include with below script :

    var MyReferenceQualifierScript = Class.create();
    MyReferenceQualifierScript.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getFilteredUsers: function(projectCategory) {
    var costCenterSysIDs = [];
    var prjGr = new GlideRecord('u_proj_category_costcenter_map');
    prjGr.addQuery('u_project_category',projectCategory);
    prjGr.query();
    while(prjGr.next()){
    var gr = new GlideRecord('cost_center');
    gr.addQuery('active', true);
    gr.addQuery('CostCenterFieldName',u_cost_center_name);
    gr.query();
    while (gr.next()) {
    costCenterSysIDs.push(gr.sys_id.toString());
    }
    }

    return 'sys_idIN' + costCenterSysIDs.join(',');
    },
    type: 'MyReferenceQualifierScript'
    });

 

  • Update advanced reference qualifier as below:
    javascript:new MyReferenceQualifierScript().getCostCenters(current.project_category);

 

If my answer has helped you then mark the solution as accepted, Thank you!

Hi,

it not working

Please share your code or screenshot.

Hi,

I new to this task. So, please guide me to slove the requirement. Already I shared my code in this post.

 

Thank you for your time and effort.