set<string> UserbusinessUnits = new set<string>();
{BusinessAnalyst_Active: {permission_set__c = BusinessAnalyst, business_Unit__c = Active} , BusinessAnalyst_VB :{permission_set__c = BusinessAnalyst, business_Unit__c = VB}, BusinessAnalyst_Retiree :{permission_set__c= BusinessAnalyst, business_Unit__c = Retiree}, Active_BC :{permission_set__c= Active_bc, business_Unit__c = Active}}
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++;
}
}`