function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rakesh SRakesh S 

how to get filed values based on another field values in custom settings

Hi All,

I have created custom settings with 4 fields and entered all values.
Please find the below image.
User-added image
My scenarios are like follows:
1). If I select country india and group exp then I want to get form list(VLS1,VLS 2,VLS 3, VLS4, VLS5, VLS6)
2).If I select country USA and group Exp then I want to get form list(VLS7,VLS 8)
3). If I select country UK and group Fresher then I want to get form list(VLS13,VLS 14,VLS 15, VLS16)
4).If I select UK then no forms

how we can get the forms besed on condition. 

I appriciate your help.

Thank you
Rakesh 
VineetKumarVineetKumar
First you will have to create a map of all the relationships and manipulate them in your code to get the result. something like below
Map<String, List<String>> mapofCountryGroup = new Map<String, List<String>>();
Map<String, List<String>> mapofGroupform = new Map<String, List<String>>();
for(<CustomSetting> thisSetting : CustomSetting.getAll().values()){
	if(mapofCountryGroup.contains(thisSetting.Country)){
		mapofCountryGroup.get(thisSetting.Country).add(thisSetting.Group);
	} else{
		mapofCountryGroup.put(thisSetting.Country, new List<String>{thisSetting.Group});
	}   
	
	if(mapofGroupform.contains(thisSetting.Group)){
		mapofGroupform.get(thisSetting.Group).add(thisSetting.Form);
	} else{
		mapofGroupform.put(thisSetting.Group, new List<String>{thisSetting.Form});
	}  
}