You need to sign in to do that
Don't have an account?

Referencing Contact in Custom Controller
Ok...here is my problem. I want to have a user select a contact related to an account from a Select List. My understanding is that the selected option is returned as a string, which in this case is the contact ID. How, in the controller do I then reference the contact. I know how to reference the contact in the Apex Page, but I want to be able to see the contact information on my next Apex Page and save the contact to a new opportunity that I am creating next.
public class testController { public Account getAccount() { return [select id, Name, Phone from Account where id = :ApexPages.currentPage().getParameters().get('id')]; } Contact contact; public String selectedContact {get;set;} public List<SelectOption> contactList; public List<SelectOption> getContact () { if (contactList == null) { List<Contact> contactee = [select id, name, contact.accountid from Contact where contact.accountid = :ApexPages.currentPage().getParameters().get('id')]; contactList = new List<SelectOption>(); for (Contact c : contactee) { contactList.add(new SelectOption(c.id,c.name)); } } return contactList; } public PageReference step2() { string acctid = ApexPages.currentPage().getParameters().get('id'); PageReference newPage = new pageReference('/apex/newQuote2?id=' + acctid); return newPage.setRedirect(true); } }
Thanks for any and all assistance.
David
could you post your VFPage code too?
ok...here is the page
Am I not making sense here? Can someone please help me. I simply want to select a contact from a contact list and be able to assign an opportunity to the contact.
This is really frustrating.
Thanks,
David
you will get the contact id in the "selectedcontact" variable. You will need to update the opportunity record with that selectedcontact assign to opportunity's contact lookup field.