function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDCsachinSFDCsachin 

Is it possible to map Lead objects custom picklist values to some other custom number field just like standard Opportunity Stage field

Here are the requirement details :

Create picklist field on Credit Score Category Lead having values (Good / Acceptable / Bad).

Create a another number field called Credit Score on Lead. The value for this field will depend on the Credit Score Category field as follows

· Credit Score category is Good then Credit Score should be set to 850.

· Credit score category is Acceptable then Credit Score should be set to 720.

· Credit score category is Bad then Credit Score should be set to 500.

Create a trigger that will encompass the above logic to set the value for the Credit Score field.

The Credit Score values should be configurable for each Credit Score category and should allow the user to modify the same without performing any code changes to the above mentioned logic. (Use custom setting).

Welcomes any sample trigger code for the same, & steps for custom setting.
harsha vardhanharsha vardhan
Hi,

Create a custom setting (Hierarchy and public type) with 3 fields(Score1, Score2 and Score3). Click on manage button on this custom setting and create a new org wide default record with proper score values given.

Field mappings:
1. Score1 -- Bad
2. Score2 -- Average
2. Score3 -- Good

Now, update your Credit Score field to formula field with the below formula.

IF( ISPICKVAL(Category__c, 'Bad')   ,  $Setup.CreditScoreMappings__c.Score1__c , IF( ISPICKVAL(Category__c, 'Average')   ,  $Setup.CreditScoreMappings__c.Score2__c , IF( ISPICKVAL(Category__c, 'Good')   ,  $Setup.CreditScoreMappings__c.Score3__c , 0)))

Trigger also can be written for the same, but I prefer configuration first. Try this out and let me know if it blocks you in any case...

Regards,
Harsha
SFDCsachinSFDCsachin
Hi Harsha,

as I am new to salesforce.com plz let me in detail steps how to add custom settings fields & its formula field.
so that I can check for what u ask me to confirm before guiding for trigger.
harsha vardhanharsha vardhan
Here it goes:

1. Go to Setup > Custom settings > New
2. Give name and select "Hierarchy" in type and "Public" in the next picklist and save it
3. Once it saved successfully, Create a new field for it.(You can find "New Field" button below the custom setting detail page)
4. Select it's type as "Number" and give name as "Score1".
5. Create two more fields in the same way naming them as "Score2" and "Score3"
6. Now, click on "Manage" button of the custom setting
7. You will find a new button on the top and just above the "Org. wide defaults", click on it
8. Enter 500 for Score1, 720 for Score2 and 850 for Score3 fields
9. Click on save

Now, come back and go to the Lead object.

1. Create a new custom field on Lead
2. Select it's type as "formula"
3. Click on "Next" and select the type as "Number" and name it as Credit Score1
4. Paste the formula code, that I have posted in my earlier post.
5. Click on "Save"

With this a formula field has been created with your requirement. And you can see the value coming automatically based on the value you selected for the Credit category.

If you want to change the Credit scores, you can go to the custom setting again and update the values there by clicking on "Manage" button.

Note: Please use your field(Credit Category) in place of Category__c.

Regards,
Harsha
harsha vardhanharsha vardhan
Field mappings:
1. Score1 -- Bad
2. Score2 -- Average
2. Score3 -- Good