BUSINESS CHALLENGE
Leads are rated based on the activity that happens with that lead. Normally, this is a field (Rating field - Value HOT, WARM and COLD) which is manually updated by the user based on the activity.
The requirement here is to update the Rating on the lead automatically based on the activity (Task, email, chatter etc).
This can be achieved in by two approaches in salesforce:
- Creating a Formula field
- Building a Flow
Let’s have a look at how to achieve this.
STEPS TO ACHIEVE THE REQUIREMENT
CREATE FORMULA FIELD
- From the home screen click on the gear icon at the top–Go to set up.
- Select object manager→ In the Quick find search and select Lead.
- Select Fields and Relationships → Click New.
- Select Formula → Click Next.
- Enter Rating as the field label → Field Name(API Name) will be populated automatically.
- Formula return type click as TEXT→ Click Next.
- Below Formula returns the Derived Rating.
IF( NOW() - CreatedDate < 30, "Hot",
IF( NOW() - CreatedDate < 60, "Warm","Cold" )
)
- Click Next.
This is one way of creating Ratings on Lead. Let's look at the other way.
CREATE FLOW
- From the Quick find search and select Flows → Click New Flow.
- Select Schedule Triggered Flow → Click Create.
- By default the layout is set to Auto Layout.
- Select (+) icon → Select Get Records Element.
- Enter Get records 30 days or older as the Label. Select Object as Lead → Choose All Conditions Are Met (AND) for the condition requirements.
- For the first condition choose Field as CreatedDate, Less than or equal as operator and value as date30daysorequal → Add another condition as Rating Does Not Equal Cold.
- Under Sort Lead Records choose All Records to store, select Choose fields and let salesforce do the rest for How to Store Record Data.
- For Select Lead Fields to store in Variable add ID, Rating, Created Date.
- Click Done.
- Click (+) icon → Select Loop Element.
- Enter Loop records as Label API Name will be auto populated.
- Select Collection variable as {!Get_records_30_days_or_older}.
- Select Direction as First item to last item.
- Click Done.
- Select (+) icon → Select Decision Element.
- Enter Label as Verify duration of the lead.
- Outcome Details as 60 days or older API Name will be auto populated →All conditions Are Met(AND).
- Enter Resource as Current item from loop loop_lead_records>created date Less than or EqualX 60daysorolder.
- Click Done.
- Select (+) icon → Select Assignment Element.
-
Set Label as set rating to cold API Name will be auto populated
-
Set Variable values as
Currentlead > Lead ID Equals to current item from loop loop_lead_Records>Lead ID
Currentlead > Rating Equals to Cold
Leadstoupdatecollection add to Current Lead
-
Click Done.
- Select (+) icon → Select Assignment Element.
-
Set Label as set rating to warm API Name will be auto populated.
-
Set Variable values as
Currentlead > Lead ID Equals to current item from loop loop_lead_Records>Lead ID
Currentlead > Rating Equals to Warm
Leadstoupdatecollection add to Current Lead
-
Click Done.
- Select (+) icon → Select Assignment Element.
-
Set Label as Get the collection count API Name will be auto populated.
-
Set Variable values as
Collection Count Equal count to lead to leads update collection
-
Click Done.
- Select (+) icon → Select Decision Element.
- Enter Label as verify collection count API Name will be auto populated.
- Outcome details Label as Collection greater than 0 API Name will be auto populated.
- Select condition requirements to All Conditions Are Met(AND).
- Select Resource to Collectioncount Greater than 0.
- Click Done.
- Select (+) icon → Select Update Records Element.
- Enter Label As Update collection API Name will be auto populated.
- Select Use the IDs and all field values from a record or record collection.
- Select Records to update as leadstoupdatecollection.
- Click Done.
- Save the Flow activate it.
WRAPPING IT UP
In this blog we have covered how to manage Ratings on Lead object using Formula or Flow.
Leave a Comment