You need to sign in to do that
Don't have an account?
Connor Reilly
Any help or guidance would be appreciated.
Thanks,
Connor
Update visualforce picklist field based on values from a string field
Hi all,
I'm looking to update a picklist on a visualforce page, based on the values from a text formula field.
Visualforce Page:
<apex:page standardController="Scorecard__c" extensions="ScorecardExtension" lightningStylesheets="true"> <apex:form > <apex:pageBlock title="Scorecard" mode="edit"> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Calculate"/> </apex:pageBlockButtons> <apex:pageBlockSection columns="2"> <apex:outputField value="{!Scorecard__c.Name}"/> <apex:outputText value=""/> <apex:outputField value="{!Scorecard__c.Revenue_M__c}"/> <apex:outputText value=""/> <apex:inputField value="{!Scorecard__c.Revenue__c}"/> <li Style="list-style:none">{!Scorecard__c.Calculate_Revenue__c}/150</li> <apex:outputField value="{!Scorecard__c.Full_NAICS_Codes__c}"/> <apex:outputText value=""/> <apex:inputField value="{!Scorecard__c.Industry__c}"/> <li Style="list-style:none">{!Scorecard__c.Calc_Industry__c}/100</li> <apex:inputField value="{!Scorecard__c.Sourcing_Frequency__c}"/> <li Style="list-style:none">{!Scorecard__c.Calc_Sourcing_Frequency__c}/100</li> <apex:inputField value="{!Scorecard__c.Role__c}"/> <li Style="list-style:none">{!Scorecard__c.Calc_Job_Function_Pick__c}/100</li> <apex:inputField value="{!Scorecard__c.Sourcing_Type__c}"/> <li Style="list-style:none">{!Scorecard__c.Calc_Sourcing_Type__c}/100</li> <apex:inputField value="{!Scorecard__c.Opportunity_Size__c}"/> <li Style="list-style:none">{!Scorecard__c.Cal_Opportunity_Size__c}/100</li> <apex:inputField value="{!Scorecard__c.Target_Pricing__c}"/> <li Style="list-style:none">{!Scorecard__c.Calc_Target_Pricing__c}/40</li> <apex:inputField value="{!Scorecard__c.Manufacturing_Processes__c}"/> <li Style="list-style:none">{!Scorecard__c.Calc_Manufacturing_Process__c}/50</li> <apex:inputField value="{!Scorecard__c.Customer_Responsiveness__c}"/> <li Style="list-style:none">{!Scorecard__c.Calc_Customer_Responsiveness__c}/85</li> <li Style="list-style:none"><apex:outputField value="{!Scorecard__c.Score__c}"/>{!Scorecard__c.Score__c}/825</li> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
If Revenue_M__c is populated, I want to update the Revenue__c field accordingly. I've started a controller extension, but don't know if that's the right way to go.
public class ScorecardExtension { private final Scorecard__c sccard; public ScorecardExtension(ApexPages.StandardController stdController) { this.sccard = (Scorecard__c)stdController.getRecord(); } public String getRevenue() { switch on this.sccard.Revenue_M__c { when '<10' { this.sccard.Revenue__c = '<$5m (or no size on Zoominfo)'; } when '11-25' { this.sccard.Revenue__c = '$5-250m'; } when '26-50' { this.sccard.Revenue__c = '$5-250m'; } when '51-250' { this.sccard.Revenue__c = '$5-250m'; } when '251-500' { this.sccard.Revenue__c = '$250m+'; } when '501-2,500' { this.sccard.Revenue__c = '$250m+'; } when '2,501-5,000' { this.sccard.Revenue__c = '$250m+'; } when '5,000+' { this.sccard.Revenue__c = '$250m+'; } when else { this.sccard.Revenue__c = 'None'; } } return this.sccard.Revenue__c; } }
Any help or guidance would be appreciated.
Thanks,
Connor
I recommend taking a look at the following sample code
See this documentation to learn more
Let me know if this helps, if it does, please close the query by marking it as solved. It may help others in the community. Thank You!