You need to sign in to do that
Don't have an account?
SOQL query for look up objects?
I have controller method which is executed when the user selects a name from th lookup contact
on a visual force page. I want the SOQL query to get the email from the parent contact object based
on the name he selected from contact object...how should my query look like?
Here is how my controller class looks like but the query in test() is not doing the job. please help.
public class customObjectExtension {
private final customObject request{get; private set;}
public String employeeEmail = null;
public customObjectExtension(ApexPages.StandardController stdController) { this.request = (customObject)stdController.getRecord();
}
public String getEmployeeEmail() {
return employeeEmail;}
public void setEmployeeEmail(String email) {employeeEmail = email;
}
public PageReference Test(){Contact info = [Select Email from Contact where
Contact.Name =: request.Employee_Name__r.Name] ;employeeEmail = info.Employee_Name__r.Email;
return null;}
}
thanks wes, yes, you are right. The problem is also with the query..(I resolved it for now..).
SELECT name, email FROM contact where id = :request.employee_name__c
I should post all of the related code from next time..I thought its too confusing but I think it is actually confusing if you
post half of the code..:)
All Answers
Hey
Can you post the code from you page as well please? A few things, your access modifiers in the controller are a bit strange, perhaps try this
private customObject request; //if it's not used in your page no need for getters & setters
private String employeeEmail = null; // you have getters and setters so no need to define this as public
}
public String getEmployeeEmail() {
return employeeEmail;}
public void setEmployeeEmail(String email) {employeeEmail = email;
}
public PageReference Test(){Contact info = [Select Email from Contact where
Contact.Name =: request.Employee_Name__r.Name] ;employeeEmail = info.Employee_Name__r.Email;
return null;}
}
Cheers,
Wes
thanks wes, yes, you are right. The problem is also with the query..(I resolved it for now..).
SELECT name, email FROM contact where id = :request.employee_name__c
I should post all of the related code from next time..I thought its too confusing but I think it is actually confusing if you
post half of the code..:)
Hi mallikam,
Do you use actionSupport to handle the rerender?
If so, which enent is used?
Thank you.