Reference qualifier with cilent script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 03:03 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 10:53 AM
Not your previous code, I am asking the code which I shared with you to try, or please share screenshot of your code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 11:10 AM
Hi,
Tried only your code, that is not working as expected. Only script include and reference qualifier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 11:12 AM
Then please share your script include code, then only I can provide solution otherwise nobody can answer to your query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 03:24 AM - edited 07-29-2025 03:27 AM
Hi @AnnamalaiS ,
Add advanced reference qualifier in the Cost center field to return cost centers related to project category
Example:
javascript: "<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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2025 03:59 AM
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:new MyReferenceQualifierScript().getCostCenters(current.project_category);
If my answer has helped you then mark the solution as accepted, Thank you!