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
Anu Raj.ax1269Anu Raj.ax1269 

Value of the record

Hi 

   I have custom object and account is lookup to my custom object field. I am able to retrieve account record value from the lookup field but I am getting the id of the record . I need to get the name of the record.

How can I achieve it?

for eg: The record name is Ac_record and is 123456609xya i am only getting id not the name of the record.

 

my code:

obj = select id, name, Location__c from customObj__c where id in: setId;
srting location = obj.Location__c;
location__c is lookup to Account

 

 

Please help me to solve this issue.

Thanks

Anu

 

 

Best Answer chosen by Admin (Salesforce Developers) 
liron169liron169

Should be simple:

 

obj = select id, name, Location__r.name from customObj__c where id in: setId;

String accountName = obj.Location__r.name;

All Answers

liron169liron169

Should be simple:

 

obj = select id, name, Location__r.name from customObj__c where id in: setId;

String accountName = obj.Location__r.name;

This was selected as the best answer
Anu Raj.ax1269Anu Raj.ax1269

thanks you r right .. i was doing the same but not the right place .. i solved it