You need to sign in to do that
Don't have an account?
PS81
Auto fill custom field based on picklist
Hi
I want to have a 2 custom field in Accounts called "Percentile" and "Probablility". The "percentile" is a picklist which has value like 10% - Deal upfront 20% - MoU etc and when ever a value is selected from "percentile" field I want to auto populate or auto fill the percentage value alone in the custom field "percentage". how to apprach this? pls advise.
I want to have a 2 custom field in Accounts called "Percentile" and "Probablility". The "percentile" is a picklist which has value like 10% - Deal upfront 20% - MoU etc and when ever a value is selected from "percentile" field I want to auto populate or auto fill the percentage value alone in the custom field "percentage". how to apprach this? pls advise.
For example, you could build a custom setting that maps Percentile values to Probabilities (e.g. "10% - Deal Upfront" --> 10%). When the Percentile changes, the trigger checks against that table to write the matching Probability to the Account. This method allows you to scale without any code updates by just adding/removing entries in the custom setting. This also allows you to use many different values that map to a single probability and wouldn't require any special formatting of the Percentile, so you could just say "Deal Upfront" maps to 10%, or "XYZ" maps to 20%, but also "ABC" maps to 20%.
A quick and dirty approach would be to just set up the Probability field as a formula. This would require that you set up the picklist values as you have lined out above. For example, the formula might look like this:
IF(LEFT(TEXT(Percentile__c),3)="100",1,VALUE(LEFT(TEXT(Percentile__c),2))/100)
The assumption here is that the formula's return type is set to Percent. This strips the number value from the first 2 characters of the picklist and divides by 100. I also added that if the first 3 characters are 100, it sets the value to 1.
A Custom Setting could be used here if you're going to go the trigger route. Your trigger should check to see if the value of the Percentile field has changed, and if so, it checks the new value against the custom setting mapping table and writes the resulting value into the account's Probability field.
They are essentially a dumbed-down type of Custom Object that typically holds static data that gets referenced in code, but can be updated by code as well. They can be incredibly useful, especially because accessing the table does not require a SOQL query.