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

Ho to display record id instead of name in DataTable?
I want to diplay a table of products prices with product ID, have found that visualforce is making autoconversion which I want to avoid.
The Apex SOQL query:
SELECT Id, Product2Id, Pricebook2Id, UnitPrice, CurrencyIsoCode, IsActive, UseStandardPrice FROM PricebookEntry WHERE // some coditions
Visualforce:
<apex:pageBlockTable id="pricesList" value="{!allPricesList}" var="price">
<!-- Id, Product2Id, Pricebook2Id, UnitPrice, CurrencyIsoCode, IsActive, UseStandardPrice -->
<apex:column headerValue="Product Id" value="{!price.Product2Id}" />
<apex:column headerValue="Pricebook Id" value="{!price.Pricebook2Id}"/>
<apex:column headerValue="CurrencyIsoCode" value="{!price.CurrencyIsoCode}"/>
<apex:column headerValue="UnitPrice" value="{!price.UnitPrice}"/>
<apex:column headerValue="UseStandardPrice" value="{!price.UseStandardPrice}"/>
<apex:column headerValue="IsActive" value="{!price.IsActive}"/>
</apex:pageBlockTable>
After page is rendered {!price.Product2Id} and {!price.Pricebook2Id} is changed to link to product/pricebook with its name. I want to have just salesforce ID here.
I tried:
{!price.Product2Id__r.Id} gives error: Invalid field Product2Id__r for SObject PricebookEntry
{!price.Product2Id.Id} error: Unknown property 'String.Id'
When I am diplaying content of List whoch hold values from SOQL which are given to VF page I see:
CurrencyIsoCode=EUR, IsActive=true, UseStandardPrice=false, Id=01uD000000B7LpVIAV, UnitPrice=1.00, Pricebook2Id=01sD0000000FE0sIAG, Product2Id=01tD0000001OvXoIAK
So conversion is made on VF page. How to stop it?
Try to change your column tag to below:
<apex:column headerValue="Product Id" >
<apex:outPutText value="{!price.Product2Id}"/>
</apex:column>
All Answers
Try to change your column tag to below:
<apex:column headerValue="Product Id" >
<apex:outPutText value="{!price.Product2Id}"/>
</apex:column>
Thank you it works perfectly.