- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 04:16 AM
Hi all,
I created two variables on catalog item.
1. country_name which is a reference type of hr_Country table
2. Entity_name which is a reference type of hr_entity table.
hr_entity table has a country field which is a reference type of hr_country table. On portal I wanted to show only entity name values based on the country selected in the country name variable.
Let's in the country_name variable if user has selected India, then in the entity_name variable it should only the India country entity_names.
How to achieve this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 04:32 AM - edited 08-29-2023 04:33 AM
Using this script in the reference qualifier of entity_name variable I'm able to achieve this
javascript: 'u_country=' + current.variables.country_name // Here 'u_country+' is the value of the field that links both the table. In my scenario u_country is the field that links the hr_Country table and hr_entity table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 04:27 AM
Hi @poornima batchu,
You can achieve that using advanced reference qualifier.
Create a script include and call that script include in the reference qualifier.
write your logic in script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 04:41 AM - edited 08-28-2023 04:42 AM
Hi @poornima batchu ,
Here's how you can set it up:
-->> Create Reference Qualifier on Entity Variable:
On the hr_entity variable (Entity_name), you can set up a Reference Qualifier to filter the available entity options based on the selected country. Go to the variable's settings, and under "Advanced Reference Qualifier", enter a script that filters the entities based on the selected country.
Example Reference Qualifier Script:
javascript:country = current.variables.country_name;
'country=' + country
-->> Create Dynamic Dependency:
For this step, you need to have the "Variable Subcategory Dependency" plugin enabled. This feature allows you to create a dynamic dependency between variables.
- Go to Variable Subcategory Dependencies (nav filter).
- Create a new record.
- Select the parent variable (country_name) and child variable (Entity_name).
- Define the conditions. In this case, you want to link the country_name selection to the filtering of Entity_name. You might need to define the conditions according to your data structure.
Now, when users select a country in the country_name field, the Entity_name field will be dynamically populated with entities that are associated with the selected country.
If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the ✅Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.
Thank you!
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 04:49 AM
can you tell me in this script i understand country_name is the value of the variable but what is the country here is it a field value in the hr_entity table
javascript:country = current.variables.country_name; 'country=' + country
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2023 05:42 AM - edited 08-28-2023 05:44 AM
Use below code in your hr_entity reference qualifies
Use correct variable names for country
Reference Qualifier-
javascript : new asu_GetEntityData().getEntity(current.variables.country_name_variable);
Script include:-
var asu_GetEntityData = Class.create();
asu_GetEntityData.prototype = {
initialize: function() {
},
getEntity: function (x ) {
var entity='';
var country =x;
var loc = new GlideRecord('hr_entity');//use correct table name
loc.addQuery('hr_country',country);//correct field names
loc.query();
if (loc.next()) {
entity = loc.sys_id;
}
return entity;
},
type: 'asu_GetEntityData'
};
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact
Thanks,
Manjusha Bangale