1

Here are the requirement details :

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

  2. 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.

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

  2. 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.

1

You can create a custom setting CreditScore__c having three custom fields:-

  1. GoodScore__c
  2. AcceptableScore__c
  3. BadScore__c

Manage your custom setting and assign values to them as 850,720 and 500 (good,acceptable and bad)respectively.

Add the following custom fields to Lead Object:-

1.picklist Customfield named 'Credit Score Category' 2. Number customfield named 'Credit Score'

Now write the following trigger:-

trigger insertCategoryScore on Lead (before Insert) {
CreditScore__c creditScore = [select AcceptableScore__c, BadScore__c, GoodScore__c from CreditScore__c ];
for (Lead leadRecord : trigger.new)
{
    if(leadRecord.Credit_Score_Category__c=='Good')
    {
        leadRecord.Credit_Score__c = creditScore.GoodScore__c ;
    }
     if(leadRecord.Credit_Score_Category__c=='Acceptable')
    {
        leadRecord.Credit_Score__c = creditScore.AcceptableScore__c;
    }
     if(leadRecord.Credit_Score_Category__c=='Bad')
    {
        leadRecord.Credit_Score__c = creditScore.BadScore__c;
    }

}

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.