You need to sign in to do that
Don't have an account?

Map two unrelated objects
List<Case> caseList = new List<Case>();
Set<ID> recordtypeset = new Set<ID>();
Set<ID> producttypeset =new Set<ID>();
for (Case eachCase : lstTriggerNew){
if(eachCase.Status == 'Ready for Assignment' && Trigger.oldMap.get(eachCase.Status)!= 'Ready for Assignment')
{ caseList.add(eachCase); }
recordtypeset.add(eachCase.RecordTypeId);
producttypeset.add(eachCase.NU_Product_Type__c);
}
if(caseList!=NULL && (!caseList.isEmpty())){
List<WorkType> WT = [SELECT ID, Name FROM WorkType WHERE NU_Case_Type__c =: recordtypeset AND NU_Product_Type__c =: producttypeset];
Highlighted above are the required WorkType and Case Lists.
Requirement: Create a map between WorkType and Case.
Constraint : Case and WorkType are not related together .
Note : There is a custom field NU_Product_Type__c which is common and required in both the objects.
Set<ID> recordtypeset = new Set<ID>();
Set<ID> producttypeset =new Set<ID>();
for (Case eachCase : lstTriggerNew){
if(eachCase.Status == 'Ready for Assignment' && Trigger.oldMap.get(eachCase.Status)!= 'Ready for Assignment')
{ caseList.add(eachCase); }
recordtypeset.add(eachCase.RecordTypeId);
producttypeset.add(eachCase.NU_Product_Type__c);
}
if(caseList!=NULL && (!caseList.isEmpty())){
List<WorkType> WT = [SELECT ID, Name FROM WorkType WHERE NU_Case_Type__c =: recordtypeset AND NU_Product_Type__c =: producttypeset];
Highlighted above are the required WorkType and Case Lists.
Requirement: Create a map between WorkType and Case.
Constraint : Case and WorkType are not related together .
Note : There is a custom field NU_Product_Type__c which is common and required in both the objects.
First of all, include NU_Case_Type__c and NU_Product_Type__c to the queried fields. After your WorkType SELECT, I propose that you create a map from case record type to product type and collect all the related WorkTypes there with following: Then to get the list for each case you can use the following:
Regards,
Mkr