Posted at 12:02 AM by Rakesh Gupta, on January 1, 2021
Big Idea or Enduring Question:
Is your Org cluttered with pending approval requests? Why not reassign the requests to a User (Chief Financial officer) or Queue? Ah, a clean org does feel good, doesn’t it?! Awesome!
An approval processis an automated process an organization can use to approve records in Salesforce. One can create, either a one-step or a multi-step, approval process in Salesforce based on business needs.
In the past, I have written a few articles related to the Approval Process and automation. Why not check them out while you are at it?!
Let us take a simple use case – Auto-Reassign Pending Request to Record Owner’s Manager.
Wait a minute, you yell! I know Salesforce enough to know that an approval request cannot be auto-reassigned to anyone unless there is automation. I know you know! So, in this article, let uslearn how to create an automation process to auto-reassign the approval process!
Objectives:
After reading this article, you’ll be able to:
Use Schedule-Triggered Flow to check for pending approval requests
Use Schedule-Triggered Flow to automatically re-assign pending approval requests to a user
Business Use case
Warren Mason, Gurukul on Cloud (GoC) awesome System Administrator, received the following requirement – develop an automated process (Which runs every morning at 08:00 am) that will automatically assign pending approval to the company’s Chief Financial officer (Nathan Gilmore) after 6 days of its initial submission if, by then, the approval is still pending.
Automation Champion Approach (I-do):
While this can be solved using various automation tools like Apex, etc, we will use Scheduled-Triggered Flow.
Before proceeding ahead, you have to understand the ProcessInstanceWorkItemobject. It represents a user’s pending approval request.
Field Name
Details
ActorId
The Id of the user who is currently responsible for approving an approval request.
OriginalActorId
The Id of the user who was originally assigned this approval request.
SystemModstamp
It is the date and time when a record was last modified by a User or by an automated process (such as a trigger.)
Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.Let’s begin building this automation process.
Guided Practice (We-do):
There are 7 steps to solve Warren’s business requirement using Schedule-Triggered Flow. We must: Read the rest of this entry!
Posted at 1:38 AM by Rakesh Gupta, on December 21, 2020
Big Idea or Enduring Question:
How can I use gamification in Salesforce to drive sales? What are the ways to automate the gamification?
Objectives:
After reading this blog post, the reader will be able to:
Create a flow that will automatically post a badge
Trigger a Flow via Process Builder
Automatically post to Chatter
Business Use case
Martin Jones is working as a System administrator at Universal Containers (UC). His organization wants to implement gamification to help boost the sales pipeline. He received a requirement from his manager if an Opportunity is closed within 7 days of its creation do the following:
Give a Deal Maker badge to the Opportunity Owner from SVP of Sales & Marketing (i.e. Tushar Gupta)
Post this info on the Opportunity Owner’s Chatter profile (see screenshot)
Automation Champion Approach (I-do):
Gamificationis the use of game mechanics (challenges, competition, scoring points, etc.) in other areas of activity. In business, it is a way to harness the competitive spirit of sales reps, the creative drive of marketers, and the desire for recognition and the reward of everyone in between. It helps your organization boost Salesforce adoption by applying proven game mechanics to reward sales representatives to drive real business results.
The three major pillars of gamification are Challenge,Competition,and Recognition.We can implement gamification in Salesforce using clicks not code. There are multiple solutions possible for the above business scenario. We will use Flow and Process Builder to solve the above business requirement. Before proceeding you have to understand the below-mentioned objects in Salesforce.
WorkBadge: – This object contains information about who the badge was given to and which badge was given.
WorkThanks: – This object represents the source and message of a thanks post.
We will useFlow to create WorkThanks, WorkBadge, and Chatter Post records. To launch the Flow whenever Opportunity getsClosed Won, we will useProcess Builder. This article will help you to understand how to implement gamification in Salesforce by using Work.com.
Before discussing it, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.
Let’s begin building this automation process.
Guided Practice (We-do):
There are 5 steps to solve Martin’s business requirement using Flow and Process Builder. We must:
Steps to setup work.com
Creating a custom label to store SVP of Sales & Marketing user-id
Creating a custom label to store badge Id
Lightning Flow Steps:
Define flow properties for auto-launched flow
Add a record variable to store an opportunity record data
Add a text variable to store message string
Create a formula to calculate elapsed days
Use a Decision element to check elapsed days
Add a create records element – create a thanks (WorkThanks) record
Add a create records element – create a badge received (Work Badge) record
Add a create records element – post thanks badge to chatter
Process Builder Steps:
Define process properties
Define evaluation criteria
Define process criteria
Add action – flows
Step 1: Setup Work.com
Follow the steps provided by Salesforce to set up work.com (some of this will need to be done in Classic).
Step 2: Creating a Custom Label to Store SVP of Sales & Marketing User’s Id
To store the ID for the SVP of Sales & Marketing, we need to get the User ID **Alternatively, you could create a variable for the ID of the specific user, but it is best practice not to hard-code User IDs**
Click Setup.
In the Quick Find box, type Custom Labels.
Click on the New Custom Labelbutton.
Enter Short Description the Name will auto-populate.
Now enter the SVP Tushar User Id in the Value.
In the Developer Console Query Editor, run the following SOQL query to get the SVP of Sales & Marketing user Id
select id from user where userrole.Name=’SVP, Sales & Marketing’
Click Save.
Step 3: Creating a Custom Label to Store Badge Id
Now we will create a Variable to store BadgeId, in this case, BadgeDeal Maker.
Click Setup.
In the User Interface, type Custom Labels.
Click on the New Custom Labelbutton.
Enter Short Description the Name will auto-populate.
Now enter the Deal Maker Badge Id in the Value.
In the Developer Console Query Editor, run the following SOQL query to get the deal maker badge Id
select id from WorkBadgeDefinition where Name =’Deal Maker’
Click Save.
Step 4.1: Lightning Flow – Define Flow Properties
Click Setup.
In the Quick Find box, type Flows.
Select Flows then click on the New Flow.
Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows:
How do you want to start building: Freeform
Click Done.
Step 4.2: Lightning Flow – Add Record Variable to Store Opportunity record data
Under Toolbox, select Manager, then click New Resource to store Opportunity record.
Input the following information:
ResourceType: Variable
API Name: varROpportunity
Data Type: Record
Object: Opportunity
Check Available for Input
Check Available for Output
Click Done.
Step 4.3: Lightning Flow – Add a Text Variable to Construct Message String
Under Toolbox, select Manager, then click New Resource to create a message for the email template.
Input the following information:
ResourceType: Variable
API Name: varTMessage
Data Type: Text
Default Value: Congratulations! You Just earned Deal Maker badge for closing the Opportunity “{!VarT_OpportunityName}” within {!Day_Elapsed} days of it’s creation.
Check Available for Input
Check Available for Output
Click Done.
Step 4.4: Lightning Flow – Create a Formula to Calculate Elapsed time
Under Toolbox, select Manager, then click New Resource to calculate elapsed time.
Step 4.5: Lightning Flow – Using Decision Element to check Elapsed Days
Drag-and-drop Decision element onto the Flow designer.
EnterLabel theAPI Name will auto-populate.
On the FirstOutcomeenter theLabel theAPI Name will auto-populate.
When to Execute Outcome: All Conditions Are Met
Row 1:
Resource: {!forNElapsedTime}
Operator: Less Than or Equal
Value: 7
Click Done.
Step 4.6: Lightning Flow – Create Records – Create a Thanks (WorkThanks) Record
If the time taken to successfully close a deal is less than 7, the next step is to create aWorkThanksrecord.
Under Toolbox, select Elements. Drag and drop Create Records onto the canvas.
Input the following information:
EnterLabel theAPI Name will auto-populate.
How Many Records to Create: One
How to Set the Record Fields: Use separate resources, and literal values
Object: WorkThanks
Set Field Values for the Thanks
Row 1:
Field: GiverId
Value: {!$Label.SVP_Tushar_User_Id}
Click Add Row
Row 2:
Field: Message
Value: {!varTMessage}
Click Done.
Step 4.7: Lightning Flow – Create Records – Create a Badge Received (Work Badge) Record
The next step is to create aWork Badgerecord.
Under Toolbox, select Elements. Drag and drop Create Records onto the canvas.
Input the following information:
EnterLabel theAPI Name will auto-populate.
How Many Records to Create: One
How to Set the Record Fields: Use separate resources, and literal values
Object: Badge Received
Set Field Values for the Badge Received
Row 1:
Field: DefinitionId
Value: {!$Label.Deal_Maker_Badge_Id}
Click Add Row
Row 2:
Field: RecipientId
Value: {!varROpportunity.OwnerId}
Click Add Row
Row 3:
Field: SourceId
Value: {!Create_WorkThanks_Record}
Click Done.
Step 4.8: Lightning Flow – Create Records – Post Thanks Badge to Chatter
The final item to create is the Chatter post.
Under Toolbox, select Elements. Drag and drop Create Records onto the canvas.
Input the following information:
EnterLabel theAPI Name will auto-populate.
How Many Records to Create: One
How to Set the Record Fields: Use separate resources, and literal values
Object: Feed Item
Set Field Values for the Feed Item
Row 1:
Field: Body
Value: {!varTMessage}
Click Add Row
Row 2:
Field: CreatedById
Value: {!$Label.SVP_Tushar_User_Id}
Click Add Row
Row 3:
Field: ParentId
Value: {!varROpportunity.Id}
Click Add Row
Row 4:
Field: RelatedRecordId
Value: {!Create_WorkThanks_Record}
Click Add Row
Row 5:
Field: Type
Value: RypplePost
Click Done.
In the end, Martin’s Flowwill look like the following screenshot:
Once everything looks good, perform the steps below:
Click Save.
Enter Flow Label theAPI Name will auto-populate.
Click Show Advanced.
API Version for Running the Flow: 50
Interview Label: Implement Gamification to Your Salesforce {!$Flow.CurrentDateTime}
Click Save.
Almost there! Once everything looks good, click the Activate button.
Our next task is to create a Process on theOpportunity object to launch a Flow, only when an Opportunity is closed won.
Step 5.1: Define Process Properties
Click Setup.
In the Quick Find box, type Process Builder.
Select Process Builder, then click New.
Name the Process and click the Tab button. The API Name will populate.
As a best practice, always input a description.
The process starts when A record changes.
Click Save.
Step 5.2: Define Evaluation Criteria
Click on the Add Object node to begin selecting the evaluation criteria.
Select the Opportunity object from the dropdown list.
Start the process when a record is created or edited.
Click Save.
Step 4.3: Define Process Criteria
Click the Add Criteria node to begin defining the process criteria.
Name the criteria.
The criteria should execute actions when the conditions are met.
Set Conditions
Row 1
Field: Opportunity | StageName
Operator: Equals
Type: Picklist
Value: Closed Won
Select All of the conditions are met (AND).
Click Advanced.
Select Yes to execute the actions only when specified changes are made to the record.
Click Save.
The reason why we would select the Yes checkbox for the question — Do you want to execute the actions only when specified changes are made to the record? — is to allow the Process Builder to execute the actions only if the record meets the criteria now, but the values that the record had immediately before it was saved didn’t meet the criteria. This means that these actions won’t be executed when irrelevant changes are made.
Step 4.4: Add Action – Flows
Below Immediate Actions, click Add Action.
For Action Type, select Flows.
Name the action.
Select the flow we just created – Implement Gamification to Your Salesforce.
Set Flow Variables:
Row 1:
Flow Variable: varROpportunity
Type: Field Reference
Value: Select the Opportunity record that started your process
Click Save.
In the end, Martin’s Processwill look like the following screenshot:
Almost there! Once everything looks good, click the Activate button.
Proof of Concept
Now onwards if a business user updates the Opportunity StagetoClosed Won, then Process Builder will automatically fire and give a badge to the opportunity owner if he closes the opportunity in less than or equals to 7 days.
Opportunity Burlington Textiles Weaving Plant Generator Third Phase is in Stage Qualification and created on 3/17/2015, 12:54 am, as shown in the following screenshot:
Now update the Opportunity status to Closed-Won and check your Chatter profile ( Currently I am logged In as Brandon Schaefer).
Independent Practice (You-do):
Create an automation that posts the Key Win badge to a user’s Feed when she closes an opportunity over $25,000. The badge should come from a Sales Executive.
Formative Assessment:
Identify a custom object in your org that should be shared based on the settings in a related object and create an autolaunched flow that will share the records without actual manual sharing
Post a picture of the sharing on Twitter@automationchamp, #AutomatedSharingwithFlow