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
Salesforce BlitzSalesforce Blitz 

get record name from record id

How do i need to fetch record name from record id in salesforce

sandeep sankhlasandeep sankhla
Hi Laxman,

You can do a simple query and get all the details of the record if you have id.

Select Id, Name, Address, Email, Phone from Account where Id =: strAccountId;

Rupal KumarRupal Kumar

Hi Laxman,

Use this query-: 
string qr = 'select id, CaseNumber from '+match+' where id='+'\'' + BrowserURLId + '\''
Recommend link-

Rupal Kumar
Salesforce BlitzSalesforce Blitz
Hi Sandeep.

Forgt to mention,..
I need to get the name without using any SQOL

Can you elaborate more on how exactly you are going to use the name or id? is from a page/trigger/apex? thanks.
Salesforce BlitzSalesforce Blitz
No..Not through page
I have a list of ids in sa controller method.

I need to get the names of the record and display them..

Hi, ok. I cannot think of way to retrieve the name but SOQL.

Try this
Set<Id> listOfIds = new Set<Id>();
// load some data into the listOfIds

List<CustomObject__c> cList = [select name from CustomObject__c where id in:listOfIds];

then use the cList to display.

alternatively if you are just using a list view you can check this link.

Anil Kumar GandlaAnil Kumar Gandla
<apex:page controller="accountdef" standardStylesheets="true" showHeader="false">
    <apex:form >
        <apex:pageBlock title="Search Account Record's Id based on Name and Vice-Versa">
            <apex:pageBlockSection >
                <apex:inputText label="Input" value="{!Text}"/>
                <apex:commandButton value="Search" action="{!GetResult}"/>
                <apex:outputText label="Output" value="{!Output}">
public class accountdef
    public string Text{get;set;}
    public string output{get;set;}
    public Void GetResult()
        if(Text!=null && Text!='')
            Account Acc=[select id,name from Account where id=:Text or name=:Text];
Malika Pathak 9Malika Pathak 9

Hi Laxman,

I am writing a code that will help you

select id,name form object name where id=:recordid

Hope it helps.