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

Tow maps merge into one list
Hi,
I have two maps and I want to merge this maps into one list, key should be the account. My goal is an overview of the accounts with the opportunities.
How can I merge these lists?
Sascha
I have two maps and I want to merge this maps into one list, key should be the account. My goal is an overview of the accounts with the opportunities.
How can I merge these lists?
public map<Id, Account> getMapFieldLabel1() { Map<Id, Account> mapField_Label1= new Map<Id, Account>([SELECT Id, Name FROM Account LIMIT 10]); return mapField_Label1; } public map<Id, Opportunity> getMapFieldLabel2() { Map<Id, Opportunity> mapField_Label2= new Map<Id, Opportunity>([SELECT Id, Account.Id, Name FROM Opportunity]); return mapField_Label2; }
<apex:pageBlockSection columns="2" collapsible="false"> <apex:repeat value="{!MapFieldLabel1}" var="item" > <apex:outputText value="{!MapFieldLabel1[item].Id}" /> <apex:outputText value="{!MapFieldLabel1[item].Name}" /> </apex:repeat> </apex:pageBlockSection> </apex:pageblock> <br/><br/> <apex:pageblock> <apex:pageBlockSection columns="3" collapsible="false"> <apex:repeat value="{!MapFieldLabel2}" var="item" > <apex:outputText value="{!MapFieldLabel2[item].Account.Id}" /> <apex:outputText value="{!MapFieldLabel2[item].Id}" /> <apex:outputText value="{!MapFieldLabel2[item].Name}" /> </apex:repeat> </apex:pageBlockSection> </apex:pageblock>Thanks,
Sascha
I get an error:
Error: Compile Error: Method does not exist or incorrect signature: void put(Account, Opportunity) from the type Map<Id,SObject>
Do you know what happen?
Thanks,
Sascha
Compile Error: Missing return statement required return type: Map<Id,Account>
If I add an RETURN STATEMENT like below:
If get an error:
Compile Error: Illegal conversion from Map<Id,SObject> to Map<Id,Account>
Do you know how can I solve this issue?
Thanks,
Sascha
Use above
Method does not exist or incorrect signature: void put(Account, Opportunity) from the type Map<Id,SObject>
which variable should be return?
if I return the finalmap I get the error:
Compile Error: Illegal conversion from Map<Id,SObject> to Map<Id,Account>
How can I return the Account Information? Error:
Invalid field AccountId for SObject Account
Error is in expression '{!Mege[item].AccountId}' in component <apex:outputText> in page map1
Any ideas?
Kindly find solution.
If you find your Solution than mark as this as a best answer.
Thanks and Regards
Suraj Tripathi.