You need to sign in to do that
Don't have an account?
Matt McFedries
Related Contacts with AccountContactRelation not showing in the Account page
Hi,
We have set up the AccountContactRelation to allow contacts to be related to multiple accounts.
For some of the accounts the contacts are not showing in the contacts related list, but in the Contact page
the related account does appear on the accounts related list.
Checking through the API the relationship appears to be perfectly created too.
Can someone guide us through ?
Cheers.
We have set up the AccountContactRelation to allow contacts to be related to multiple accounts.
For some of the accounts the contacts are not showing in the contacts related list, but in the Contact page
the related account does appear on the accounts related list.
Checking through the API the relationship appears to be perfectly created too.
Can someone guide us through ?
Cheers.
Hope below code will help you,
<apex:repeat value="{!accounts}" var="accWrap">
<apex:outputText value="User ID : {!accWrap.userId}"/>
<apex:repeat value="{!accWrap.accounts}" var="acc">
<apex:outputText value="Account : {!acc.Name}"/>
<apex:repeat value="{!acc.contacts}" var="cont">
<apex:outputText value="Contact : {!cont.Name}"/>
</apex:repeat>
</apex:repeat>
</apex:repeat>
Controller:
public class accountcontact
{
list<AccountWrapper> wraplist=new list<AccountWrapper>();
public accountcontact()
{
Map<Id, AccountWrapper> accMap=new Map<Id, AccountWrapper>();
for(account a:[SELECT CreatedbyID,Account.Name,(SELECT
name,Contact.FirstName, Contact.LastName
FROM Account.Contacts) FROM Account])
{
AccountWrapper accWrap=accMap.get(a.CreatedByID);
if (null==accWrap)
{
accWrap=new AccountWrapper();
accMap.put(a.CreatedByID, accWrap);
accWrap.userId=a.CreatedById;
}
accWrap.accounts.add(a);
}
wrapList=accMap.values();
}
public list<AccountWrapper> getaccounts()
{
return acclist;
}
public class AccountWrapper
{
public Id userId {get; set;}
public List<Account> accounts {get; set;}
public AccountWrapper()
{
accounts=new List<Account>();
}
}
}