function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Stephen E 4Stephen E 4 

Display Names of relationships while dynamically creating visualforce page bindings?

Hey all,

I have some custom visualforce/apex that I wrote to merge custom object records. It works well, though the one issue we have is displaying "friendly names" rather than the ids when it comes to lookup/master detail fields.

Below is part of the visualforce page code. 

'fields' is a list of the objects fields.

'mergedAsset' is a new sObject (i.e. custom_object__c CO = new custom_object__c()) 

assetToGet is record 1 (custom_object__c)

assetGot is record 2 (custom_object__c)

You loop through the fields dynamically creating radio buttons for user selection. though, on relationship fields it displays the lookups id. Is there a way you can see to display the actualy name of the record rather than the id?
<apex:repeat value="{!fields}" var="mf">
             <apex:selectRadio value="{!mergedAsset[mf]}" layout="pageDirection" disabled="{!IF(assetToGet[mf] = assetGot[mf],true,false)}">
                            <apex:selectOption itemLabel="{!assetToGet[mf]}" itemValue="{!assetToGet[mf]}" ></apex:selectOption>
                            <apex:selectOption itemLabel="{!assetGot[mf]}" itemValue="{!assetGot[mf]}" ></apex:selectOption>