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

Field Dependencies and Default Values for Custom Object
I went through a bit of work to set up a lot of field dependencies and default values for a custom object which is a customer survey. In the default layout everything is fine but the look and feel is horrid so I am attempting to create my first visualforce pages. The field dependencies and default values don't seem to work in vf. So I need to be able to set these things by hand I am guessing by using a controller extension? Could someone give me a simple example of a yes or no picklist that causes the values to change in a second picklist and also a simple example of a picklist with a default value automatically selected. Mine always have --None-- selected even though there are default values defined in the custom object...Thanks!
Hi,
Here is an example of 2 picklists, the first one is defaulted to "New Customer" and the value of the second one depends on the first one :
-------------------VF Page------------------------------------------- <apex:page controller="PickListSample"> <apex:form id="form1"> <apex:actionFunction action="{!updatePL}" name="update" reRender="field2" /> <apex:pageBlock id="block1"> <apex:inputField value="{!opp.Type}" onchange="update();" /> <apex:inputField value="{!opp.LeadSource}" id="field2"/> </apex:pageBlock> </apex:form> </apex:page> ---------------------Controller-------------------------------------- public class PickListSample { public Opportunity opp = new Opportunity(); public Opportunity getOpp(){ opp.Type = 'New Customer'; return opp; } public pagereference updatePL(){ if(opp.Type=='Existing Customer - Upgrade'){ opp.LeadSource='Other'; }else if (opp.Type=='Existing Customer - Replacement'){ opp.LeadSource='Purchased List'; }else if (opp.Type=='Existing Customer - Downgrade'){ opp.LeadSource='Partner Referral'; } return null; } }
There are many ways of dealing with that, this is just one example among many other possibilities.
Hope this helps.
Catherin.