+ Start a Discussion

how to retrieve a value

Is there a way to retrieve a value from a specific custom field from a specific account?
SOQL Query?  http://www.salesforce.com/us/developer/docs/soql_sosl/

Account test = [SELECT CustomField__c FROM Account WHERE Id = '(...insert specific Id here...)'  LIMIT 1];

I tried using your recommendation but i get an "Error: Compile Error: invalid ID field"

Account test = [SELECT testfield__c FROM Account WHERE Id = '(001i000000UP1gF)'  LIMIT 1];
Nirmal ChristopherNirmal Christopher
Nirmal Christopher
Hi jcaldito, Pls cross check the provided id correct.
try something like this

Account test = [SELECT testfield__c FROM Account WHERE Id =:  '001i000000UP1gF'  LIMIT 1];
ok. so i am getting error.

Error: Compile Error: Return value must be of type: Account at line 4 column 5
Can someone tell me what I am doing wrong?

public class mySecondController {

  public Account getAccount() {
    return [SELECT Factor_Rate__c FROM Account WHERE Id =:  '001i000000UP1gF'  LIMIT 1];

public String getName() {
   return 'My Second Custom Controller';

From the prefix it appears you are using an Account Id but check your Id one more time... I pasted this code into a DE and replaced the Id with a specific record in my org and the class compiled no problem.
wierd. I am using: https://na15.salesforce.com/001i000000UP1gF from the DE org (Genepoint account)
ok. I started over and it finally compiled. But I am still having problems getting the lender name to show in my VF page.

public Lender__c getLender() {
    return [SELECT Lender_name__c FROM Lender__c WHERE Id =:  'a0kJ0000000xnD9'  LIMIT 1];

<apex:outputField value="{!Worksheet__c.Get_Lender__r.Lender_name__c}"/>

please help. thanks
You can reference the field directly as the getter method makes it public and accessable. The getLender() method creates a variable named 'lender' of type Lender__c

<apex:outputField value="{!lender.Lender_Name__c}" /> 

for more information: http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_controller_getter_methods.htm
it's giving me....  Error: Unknown property 'Worksheet__cStandardController.lender'

so when I add worksheet__c to <apex:outputField value="{!worksheet__c.lender.Lender_Name__c}" />

I get an error: Error: Invalid field lender for SObject Worksheet__c