I have a Map of Permission set and the business Unit like below, the map is being generated from a custom setting
Map<string, Allow_disposition__c> adobj = new Map<string, allow_Disposition__c>(); for(Allow_Disposition__c vaObj: Allow_Disposition__c.getall().values()){ adobj.put(vaobj.Name, vaObj); } system.debug('198 -- Map : '+adobj); String profileName = [SELECT Name FROM Profile WHERE Id =: UserInfo.getProfileId()].name; system.debug('User Profile Name :'+ProfileName); // if user has system admin skip the logic and enable permission, else run the logic and give appropriate permission if(profileName != 'System Administrator'){ //Not system admin, run the logic for(PermissionSetAssignment PSAobj : [SELECT Id, PermissionSetId, PermissionSet.Name, AssigneeId FROM PermissionSetAssignment WHERE AssigneeId =:UserInfo.getuserId() AND PermissionSet.isOwnedByProfile = false]){ psets.add(PSAObj.PermissionSet.Name); system.debug('214 --- Psets'+psets); for(integer i=0;i<=adObj.size(); i++){ if(adobj.containsKey(PSAObj.PermissionSet.Name)){ //this won't work now because the **Key** does not contain Business Analyst, Rather it contains Business Analyst_VB and busienss_Analyst_Active and so forth. system.debug('218 -- Permission Set Bs :'+adobj.get(PSAObj.PermissionSet.Name).business_unit__c); userbusinessUnits.add(adobj.get(PSAObj.PermissionSet.Name).business_unit__c); } i++; } }` How do I retrieve all values of Business_Unit__c for the field permission_set__c business Analyst from the value and add it to the set above? I am not able to add that permission_set__c field as key because Map will only save one unique key so in custom settings I have added data as above. I want to retrieve All business Unit values for businessAnalyst permission set, and I am getting BusinessAnalyst name from the SOQL on permission set assignment object which also matches the value in permission_set__c field.