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
    Commented Apr 25, 2017 at 10:51
  • How do you mean?
    – user37980
    Commented Apr 25, 2017 at 10:54
  • use for loop and loop over both the list
    – d_k
    Commented Apr 25, 2017 at 10:56

1 Answer 1

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

AND

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .