+ Start a Discussion
Shifs SalheenShifs Salheen 

Retrieve lookup field name instead of Id in VF page

Hi,
I have a Business Goal Object ,now in Campaign ,Business Goal is a lookup field.In list page,I want to display Business Goal NAme instead of Id.
Somewhere I read use Business_Goal__r.Name .But when I do this, it gives error that "
SObject row was retrieved via SOQL without querying the requested field: Campaign.Business_Goal__r 
"
Best Answer chosen by Shifs Salheen
Martijn SchwarzerMartijn Schwarzer
Hi Shifs,

You will want to include the following fields in your query:

Business_Goal__c (This is the ID field)
Business_Goal__r.Name (this is the Name field of the related Business_Goal__c record.

You will want to display Business_Goal__r.Name in your list.

Please let me know if this works for you.

Best regards,
Martijn Schwärzer

Ps. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

All Answers

Martijn SchwarzerMartijn Schwarzer
Hi Shifs,

You will want to include the following fields in your query:

Business_Goal__c (This is the ID field)
Business_Goal__r.Name (this is the Name field of the related Business_Goal__c record.

You will want to display Business_Goal__r.Name in your list.

Please let me know if this works for you.

Best regards,
Martijn Schwärzer

Ps. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.
This was selected as the best answer
Shifs SalheenShifs Salheen
Thanks a lot...It worked !!!