You need to sign in to do that
Don't have an account?
StephenYS10000
Dynamic picklist connected to custom object
I was wondering if somebody could help me. I have create a dynamic picklist controller that collects it select list from a custom lookup table
I have a custom field called Municapaly on the Account object and I would like to link and update this field from this new controller
<apex:page standardController="Account" > <apex:form > <tr><td>Municapaly</td><td> <c:Municapaly_Dynamic_Picklist myvalue="1"> </c:Municapaly_Dynamic_Picklist> </td> <tr> </apex:form></apex:page> <apex:page standardController="Account" > <apex:form > <tr><td>Municapaly</td><td> <c:Municapaly_Dynamic_Picklist myvalue="1"> </c:Municapaly_Dynamic_Picklist> </td> <tr> </apex:form></apex:page> public class clsMuniciplayDynamicPicklist{ private List<SelectOption> items; public List<SelectOption> getItems() { List<SelectOption> items = new List<SelectOption>(); //default value items.add(new SelectOption('','--Select Record Type --')); for (Lookup_Tables__c lt: [Select l.Type__c, l.Start_Date__c, l.Name, l.End_Date__c, l.Code__c From Lookup_Tables__c l]){ items.add(new SelectOption( lt.Code__c,lt.Name)); } return items; }
}
Can you paste your code in via the insert code button (clipboard symbol with a C on it).
Otherwise the formatting means we can't understand it without reformatting ourselves.
Thanks for showing me how to insert code. It's a big help.
Below is the code showing the page, controller and class code
The problems that I have at the moment are as follows
1) How do I link the underlying Municilpaly record to display as the select Municilpaly?
2) If the user selects a different Municilpaly how does one save the value to the Account object?
apex:page standardController="Account" > <apex:form > <tr><td>Municapaly</td><td> <p>test {!account.Municipaly__c}</p> <c:Municapaly_Dynamic_Picklist defaultvalue="(!account.Municipaly__c"> </c:Municapaly_Dynamic_Picklist> </td> <tr> </apex:form> </apex:page> <apex:component controller="clsMuniciplayDynamicPicklist" > <apex:attribute name="defaultvalue" description="Dynamic Picklist value" type="String" required="true"></apex:attribute> <apex:selectList value="{!defaultvalue}" size="1"> <apex:selectOptions value="{!items}"> </apex:selectOptions> </apex:selectList></apex:component> public class clsMuniciplayDynamicPicklist { private Account CurrentAccount; public string defaultvalue{get;set;} private List<SelectOption> items; public List<SelectOption> getItems() { List<SelectOption> items = new List<SelectOption>(); for (Lookup_Tables__c lt: [Select l.Type__c, l.Start_Date__c, l.Name, l.End_Date__c, l.Code__c From Lookup_Tables__c l]){ items.add(new SelectOption( lt.Code__c,lt.Name)); } return items; } }
Hi Gino
Could you please provide me a code snippnet on how I would bind the field directly to the custom field once the account has been passed from the custom component.
Thanks
Stephen
Stephen,
Did you manage to find the code snippet that dinamically binds the custom component to the custom field in the "page object"?
You could post the code, I would greatly appreciate it.
Thanks in advance,
Luís Silva
Take a look at this link - Dynamically add values to picklist using Visualforce