0

I need to get two sets of picklist values as strings however no matter what i do list/set etc i get an illegal assignment the only resolution is to have the sets as lists and as the SObject which means i cant add all to the third set and use the retain all to keep the matching values

Current

//Declare sets

list<Asset> ProductFamiliesAssests = [Select module__C from Asset where accountid in :Accountids];
List<OpportunityLineItem> ProductFamiliesOpps = [Select id from OpportunityLineItem where opportunityid in :oppsid];
set<Asset> thirdSet = new Set<Asset>();

//Add OppAssetFamily and AssetassetFamily to set

thirdSet.addAll(ProductFamiliesAssests);

//Keep Matches in thirdSet

thirdSet.retainAll(ProductFamiliesOpps);

//Check Criteria and Set Opp Type

Ideal -

//Declare sets

Set<String> ProductFamiliesAssests = [Select module__C from Asset where accountid in :Accountids];
Set<String> ProductFamiliesOpps = [Select Module__C from OpportunityLineItem where opportunityid in :oppsid];
set<String> thirdSet = new Set<String>();

//Add OppAssetFamily and AssetassetFamily to set

thirdSet.addAll(ProductFamiliesAssests);

//Keep Matches in thirdSet

thirdSet.retainAll(ProductFamiliesOpps);

//Check Criteria and Set Opp Type
3
  • Why don't you loop through the list and populate the sets? – d_k Apr 25 '17 at 10:51
  • How do you mean? – user37980 Apr 25 '17 at 10:54
  • use for loop and loop over both the list – d_k Apr 25 '17 at 10:56
0
for (Asset opp : lists) {
    thirdSet.add(opp.Module__c);
 }

AND

for (OpportunityLineItem opp : lists) {
    thirdSet.add(opp.Module__c);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.