You need to sign in to do that
Don't have an account?
Giancarlo Amati
how to populate a multipick list with no VF page
Hi Everyone,
every Opportunity has an Account linked to it. Every Account has a child (custom object) BCAccount record list. 1 Account can have multiple BCAccount records.
The opportunity has now a field BCAccountOpty which is a multi picklist field.
I have created the following method in a Class:
I cannot figure out what I feel I need to build a 'for' loop over a List<SelectedOption> objects on the 'avlBCAccounts' variable. But what is the method to populate the actual BCAccountOpty field?
every Opportunity has an Account linked to it. Every Account has a child (custom object) BCAccount record list. 1 Account can have multiple BCAccount records.
The opportunity has now a field BCAccountOpty which is a multi picklist field.
I have created the following method in a Class:
public static Map<String, BCAccount__c> getBCAccountsForAccount(Set<Id> accountIds) { Map<String, BCAccount__c> bcaccountMap = new Map<String, BCAccount__c>(); if(accountIds.size() > 0 ){ for(BCAccount__c bcAccount : [Select Id, name, Account__c, recordTypeId, BCAccountId__c, Account__r.ownerId from BCAccount__c where Account__c in :accountIds ]){ bcaccountMap.put(bcAccount.BCAccountId__c, bcAccount); } } return bcaccountMap; } /*Builds the list of Available BCAcount from the Account.Id*/ public static void getBCAccounts(Opportunity optyObj) { Map<String, String> availableBCAccountsMap; Set<Id> accountIds = new Set<Id>(); accountIds.add(optyObj.accountId); Map<String, BCAccount__c> bcAccountMap = getBCAccountsForAccount(accountIds); if(!bcAccountMap.isEmpty()){ for(BCAccount__c bcAccount : bcAccountMap.values()){ availableBCAccountsMap.put(bcAccount.BCAccountId__c, bcAccount.Name); } } }and one opportunity trigger which now looks like below. Now I need to populate the field "BCAccountOpty" when the opportunity is edited.
I cannot figure out what I feel I need to build a 'for' loop over a List<SelectedOption> objects on the 'avlBCAccounts' variable. But what is the method to populate the actual BCAccountOpty field?
trigger OpportunityAvlbBCAccounts on Opportunity (after delete, after insert, after undelete, after update, before delete, before insert, before update) { List<SelectOption> avlBCAccounts = new List<SelectOption>(); if(Trigger.isBefore){ if(Trigger.isInsert || Trigger.isUpdate){ Opportunity_GET_BCAccountUtils.getBCAccounts(trigger.new[0]); avlBCAccounts = Opportunity_GET_BCAccountUtils.getAvailableBCAccounts(); for (List<SelectOption> c : avlBCAccounts) { } } } }
Thank you.
GC
Were you able to resolve the issue??
Regards,
Anutej