I am using a custom VF page to display duplicate records when a lead conversion occurs.

My class will return to the VF page an error message, with the duplicate records, and the VF Page will display them, and using a radio button, will select if to merge the new contact/account into an existing record, or create a new one.

It works fine if I only have a duplicate contact. But if I have a duplicate account, I get render error (which is ok, as the field: accountid is missing from the account object).

This is my relevant VF page:

<apex:pageBlock title="Duplicate Records" rendered="{!hasDuplicateResult}">
    <apex:pageMessages />
    <apex:pageBlockTable value="{!duplicateRecords}" var="item">
        <apex:column headerValue="Select to Merge">
            <input type="radio" name="selectRadio" id="radio">
            <apex:actionSupport event="onclick" action="{!setSelectedContactToMerge}" reRender="mergeButton">      
                <apex:param name="selectedMergedContactId" value="{!item['Id']}"/>
                <apex:param name="selectedMergedAccountId" value="{!item['AccountId']}"/>
        <apex:column >
            <apex:facet name="header">Name</apex:facet>
            <apex:outputLink value="/{!item['Id']}">{!item['Name']}</apex:outputLink>
        <apex:column >
            <apex:facet name="header">Owner</apex:facet>
            <apex:outputField value="{!item['OwnerId']}"/>
        <apex:column >
            <apex:facet name="header">Account</apex:facet>
            <apex:outputField value="{!item['AccountId']}"/>
        <apex:column >
            <apex:facet name="header">Last Modified Date</apex:facet>
            <apex:outputField value="{!item['LastModifiedDate']}"/>

When getting back duplicate results of accounts, the line:

 <apex:outputField value="{!item['AccountId']}"/>

Will throw an error. I need it to be:

 <apex:outputField value="{!item['Id']}"/>

I have a field in my controller, that will set if the results are Account objects or not:

isDuplicateAccount = true;

But I can't make the display on the VF page conditional to this variable.

Your assistance is welcome.


you can render correct outputField based on isDuplicateAccount value

<apex:outputField rendered="{! NOT(isDuplicateAccount)}" value="{!item['AccountId']}"/>
<apex:outputField rendered="{! isDuplicateAccount}" value="{!item['Id']}"/>

or by using IF logic formula

<apex:outputField value="{!item[IF(isDuplicateAccount, 'Id', 'AccountId')]}"/>

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.