You need to sign in to do that
Don't have an account?
Display related lookup objects instead of searching
We want to display related lookup objects in a picklist when an opporunity is being created. In the opportinuty we have a lookup to brands. Brands are related to accounts. We want a pick list of brands when an account is selected when a new opportunity is being created.
I am using the standard opportunity controller with an extension. The extension can not use the account id on the opportunity untill the opportunity is saved. How can I reference the account on the opportunity?
Here is the logic that does not work:
public Test1_OppExtension(ApexPages.StandardController stdController) {
this.o = (Opportunity)stdController.getRecord();
}
//builds a picklist of account names based on their account id
public List<SelectOption> getBrands() {
List<SelectOption> options = new List<SelectOption>();
//new list for holding all of the picklist options
options.add(new selectOption('', '- None -'));
if(o.AccountId != null){
id account_id;
account_id = Opportunity.AccountId ;
for (Brand__c brand : [select b.id, b.name From Brand__c b where b.Advertiser__c =: o.account_id ]){
options.add(new selectOption(brand.id, brand.Name));
}
}
return options;
}