+ Start a Discussion
Sales Force FRMSales Force FRM 

How to get the value of a custom field which is of data type Lookup(Opportunity)

    Hi Folks,
                      I have created a custom field which is of type Lookup(Opportunity) in Custom object ,now i need to get the value of
custom filed , for example if in custom field look up value  is 'good opportunity' then i need to get the values of a custom field as
'good opportunity' , can any of you help me!

Regards,
Rajeshwar.
micwamicwa
That Lookupfield (ex. OpportunityId__c) is of type ID and holds the Id of the selected Opportunity. So to get the name you must query it:

Code:
String oppName = [Select o.Name from Opportunity o where o.Id = :customObject.OpportunityId__c].Name;