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

Not your previous code, I am asking the code which I shared with you to try, or please share screenshot of your code

Hi,

Tried only your code, that is not working as expected. Only script include and reference qualifier.

 

 

 

Then please share your script include code, then only I can provide solution otherwise nobody can answer to your query.

G Ponsekar
Mega Guru

Hi @AnnamalaiS ,

 

Add advanced reference qualifier in the Cost center field to return cost centers related to project category

Example:

 

javascript&colon; "<project_field_in_costcenter_table>="+current.u_project_category

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

Thanks,

GP

priyanka1028
Tera Contributor

Hi @AnnamalaiS ,

 

I believe the Cost Center table has a field named Project Category. If that's the case, please follow the steps below:

  • Create script include with below script :
    var MyReferenceQualifierScript = Class.create();
    MyReferenceQualifierScript.prototype = Object.extendsObject(AbstractAjaxProcessor, {
    getCostCenters: function(projectCategory) {
    var costCenterSysIDs = [];
    var gr = new GlideRecord('cost_center');
    gr.addQuery('active', true);
    gr.addQuery('project_category', projectCategory);
    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&colon;new MyReferenceQualifierScript().getCostCenters(current.project_category);

 

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