How to get one variable value from choice table dependent on another variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 03:11 AM
Hi All,
I have created two variables on the record producer. Variable one name is country and variable two name is state. Variable one is of choice type and variable two is a reference and is referring to choice table. Variable two is dependent on variable one, so if the country is selected in variable one then variable two should show only that states based on the country and state value is coming from choice table. So how can we achieve this?
Thanks
- Labels:
-
Human Resources Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 03:36 AM
Hi @Sumer Sharma ,
Please check the below references:
Creating Dependent Variables in Service Catalog
Dependent variable on Catalog item
Dependent Select Box (Choice) Variables on Record Producers
Mark this as Helpful / Accept the Solution if this helps
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 04:16 AM
Hello @Sumer Sharma,
This use case can be best fit for the display business rule. Can you tell me where you want to implement client side or the server side so that I can elaborate my answer more effectively.
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 04:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 05:06 AM
Hello @Sumer Sharma,
You can try using script include shared below let me know if you need help.
Script Include:
var FilterStates = Class.create();
FilterStates.prototype = {
getStatesByCountry: function(country) {
//You check if the country is empty. If it is you don't include it in the reference qualifier and return.
if (!country) return '';
var stateList = [];
var stateGr = new GlideRecord('your_state_table');
stateGr.addQuery('your_country_field', country);
stateGr.query();
while (stateGr.next()) {
stateList.push(stateGr.getUniqueValue());
}
return "sys_idIN" + stateList.join(',');
},
type: 'FilterStates'
};
Thank you!