populating value using reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-05-2024 12:18 AM
I have two catalog variables, comp and comp lead , comp is referencing to a table, if I select a value in comp then comp lead will also needs to be auto populated, comp is referencing to a table there is a column called lead , we need to populate that lead value in comp lead, how can we achieve this with script include and ref qualifier
by glideajax we can do but our requirement to use ref qualifier.
thanks in advance......

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-05-2024 12:21 AM
@Amit Dey1 This can only be done via an onChange client script on comp field. Reference qualifier can be used to filter the values in the reference field, however it doesn't auto populate the value on the reference field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-05-2024 12:24 AM
Hi @Amit Dey1,
To achieve the auto-population of the comp_lead variable based on the selection in the comp variable using a reference qualifier, you can follow these steps:
Create a Script Include:
- Create a new Script Include in ServiceNow. This script will contain a function that retrieves the necessary data based on the selected value of comp.
var CatalogUtils = Class.create();
CatalogUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getLeadForComp: function(compValue) {
var leadValue = '';
// Query the 'comp' table to retrieve the lead value based on compValue
var compGR = new GlideRecord('comp');
if (compGR.get(compValue)) {
leadValue = compGR.lead.toString(); // Assuming 'lead' is a reference field or string field
}
return leadValue;
},
type: 'CatalogUtils'
});
2. Configure the Reference Qualifier:
- In your comp_lead variable, set up a reference qualifier to filter the records based on the value selected in com
javascript: new CatalogUtils().getLeadForComp(current.variables.comp.toString());
ā
This reference qualifier uses the Script Include method getLeadForComp to dynamically filter the comp_lead choices based on the selected comp value.
Thank you, please make helpful if you accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-05-2024 12:27 AM
Hi @Amit Dey1 ,
If you want to auto-populate comp lead variable based on comp variable, you van use Auto-populate feature in the variable configuration.
Refer this article for detailed steps: https://www.servicenow.com/community/developer-articles/auto-populate-a-variable-based-on-a-referenc...
Thanks.
Hope it helps.
If my response turns useful please mark it helpful and accept solution š.