Implement Gamification to Your Salesforce

Advertisements

Last Updated on December 11, 2022 by Rakesh Gupta

Big Idea or Enduring Question:

How can I use gamification in Salesforce to drive sales?  What are the ways to automate gamification?

Objectives:

After reading this blog post, the reader will be able to:

  • Create a flow that will automatically post a badge
  • Learn how to use a Decision element to find whether a Record variable or a Record collection variable contains a record
  • Use decision element to validate the data
  • Automatically post to Chatter
  • and much more

Business Use case

Martin Jones is working as a System administrator at Gurukul On Cloud (GoC). 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 the SVP of Sales & Marketing  (i.e., Tushar Gupta)
  • Post this info on the Opportunity Owner’s Chatter profile (see screenshot)

Gamification in Salesforce

Automation Champion Approach (I-do):

Gamification is 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 for driving actual 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 Record-Triggered Flow to solve the above business requirement. Before proceeding, you have to understand the below-mentioned objects in Salesforce.

  1. WorkBadge: – This object contains information about who the badge was given to and which badge was given.
  2. WorkThanks: – This object represents the source and message of a thanks post.

We will use Flow to create WorkThanks, WorkBadge, and Chatter Post records. To launch the Flow whenever Opportunity gets Closed Won. 

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes going through the following Flow diagram and understand it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 4 steps to solve Martin’s business requirement using Record-Triggered Flow. We must:

  1. Steps to set up work.com
  2. Creating a custom label to store the SVP of Sales & Marketing user-id
  3. Creating a custom label to store badge Id
  4. Salesforce Flow Steps:
    1. Define Flow properties
    2. Add a text variable to construct a Chatter Post Message
    3. Create a formula to calculate elapsed days 
    4. Use a Decision element to check elapsed days
    5. Add a create records element  – create a thanks (WorkThanks) record
    6. Add a create records element  – create a badge received (Work Badge) record
    7. Add a create records element  – post thanks badge to chatter 

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

    1. Assign a Work.com Administrator
    2. Enable Work.com Features
    3. Assign Work.com Permission Sets

Step 2: Creating a Custom Label to Store the 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**

  1. Click Setup.
  2. In the Quick Find box, type Custom Labels.
  3. Click on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the SVP Tushar User Id in the Value.
    1. In the Developer Console Query Editor, run the following SOQL query to get the SVP of Sales & Marketing user Id
      1. select id from user where userrole.Name=’SVP, Sales & Marketing’
  6. Click Save.

Step 3: Creating a Custom Label to Store Badge Id

Now we will create a Variable to store BadgeId, in this case, Badge Deal Maker.

  1. Click Setup.
  2. In the User Interface, type Custom Labels.
  3. Click on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the Deal Maker Badge Id in the Value.
    1. In the Developer Console Query Editor, run the following SOQL query to get the deal maker badge Id
      1. select id from WorkBadgeDefinition where Name =’Deal Maker’
  6. Click Save.

Step 4.1: Define Flow Properties 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows, then click on the New Flow.
  4. Select the Record-Triggered Flow option, click on Create and configure the flow as follows:
    1. Object: Opportunity
    2. Trigger the Flow When: A record is created or updated
    3. Set Entry Criteria
      1. Condition Requirements: None
    4. Optimize the Flow For Action and Related Records
  5. Click Done.

Step 4.2: Add a Text Variable to Construct a Chatter Post Message

  1. Under Toolbox, select Manager, then click New Resource to create a message for Chatter Post. You can also use Text Template. 
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varT_Message
    3. Data Type: Text
    4. Default Value: Congratulations! You Just earned Deal Maker badge for closing the Opportunity “{!$Record.Name}” within {!Day_Elapsed} days of it’s creation.
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 4.3: Create a Formula to Calculate Elapsed time

  1. Under Toolbox, select Manager, then click New Resource to calculate elapsed time. 
  2. Input the following information: 
    1. Resource Type: Formula
    2. API Name: forN_ElapsedTime
    3. Data Type: Number
    4. Decimal Places: 2
    5. Formula: {!$Record.LastModifiedDate} – {!$Record.CreatedDate}
  3. Click Done.

Step 4.4: Using Decision Element to check Elapsed Days

Now we will use the Decision element to check the opportunity stage and elapsed time. 

  1. On Flow Designer, click on the +icon and select the Decision element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Under Outcome Details, enter the Label the API Name will auto-populate.
  4. Condition Requirements to Execute OutcomeAll Conditions Are Met (AND)
    1. Row 1:
      1. Resource: {!forN_ElapsedTime}
      2. Operator: Less Than or Equal
      3. Value: 7
    2. Click Add Condition
    3. Row 2:
      1. Resource: {!$Record.StageName}
      2. Operator: Equals
      3. Value: Closed Won
  5. Click Done.

Step 4.5: 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 a WorkThanks record. 

  1. On Flow Designer, below the <= 7 node, click on the +icon and select the Create Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Input the following information:
    1. How Many Records to Create: One
    2. How to Set the Record Fields: Use separate resources, and literal values
    3. Object: WorkThanks
    4. Set Field Values for the Thanks
    5. Row 1:
      1. Field: GiverId
      2. Value: {!$Label.SVP_Tushar_User_Id}
    6. Click Add Row
    7. Row 2:
      1. Field: Message
      2. Value: {!varT_Message}
  4. Click Done.

Step 4.6: Create Records – Create a Badge Received (Work Badge) Record

The next step is to create a Work Badge record.

  1. On Flow Designer, click on the +icon and select the Create Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Input the following information:
    1. How Many Records to Create: One
    2. How to Set the Record Fields: Use separate resources, and literal values
    3. Object: Badge Received
    4. Set Field Values for the Badge Received
    5. Row 1:
      1. Field: DefinitionId
      2. Value: {!$Label.Deal_Maker_Badge_Id}
    6. Click Add Row
    7. Row 2:
      1. Field: RecipientId
      2. Value: {!$Record.OwnerId}
    8. Click Add Row
    9. Row 3:
      1. Field: SourceId
      2. Value: {!Create_WorkThanks_Record}
  4. Click Done.

Step 4.7: Create Records – Post Thanks Badge to Chatter 

The final item to create is the Chatter post.

  1. On Flow Designer, click on the +icon and select the Create Records element.
  2. Enter a name in the Label field; the API Name will auto-populate.
  3. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: Feed Item
    5. Set Field Values for the Feed Item
    6. Row 1:
      1. Field: Body
      2. Value: {!varTMessage}
    7. Click Add Row
    8. Row 2:
      1. Field: CreatedById
      2. Value: {!$Label.SVP_Tushar_User_Id}
    9. Click Add Row
    10. Row 3:
      1. Field: ParentId
      2. Value: {!$Record.Id}
    11. Click Add Row
    12. Row 4:
      1. Field: RelatedRecordId
      2. Value: {!Create_WorkThanks_Record}
    13. Click Add Row
    14. Row 5:
      1. Field: Type
      2. Value: RypplePost
  4. Click Done.

In the end, Martin’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter the Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 56
  5. Interview Label: Implement Gamification to Your Salesforce – Flow {!$Flow.CurrentDateTime}
  6. Click Save

Almost there! Once everything looks good, click the Activate button.  

Proof of Concept

Suppose a business user updates the Opportunity Stage to Closed Won. In that case, the record-trigger flow will automatically fire and give a badge to the opportunity owner if he closes the opportunity in less than or equal to 7 days. 

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

I want to hear from you!

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? Feel free to share in the comments below.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!
Preferred Timing(required)

21 thoughts on “Implement Gamification to Your Salesforce

  1. Hi ,
    I am New to Communities, Trying to setup Badges for my org and working fine in Communities ,My requirement to see the Badges available in Communities
    How to query the Gamification Badges?

  2. Is there a way to build in a logic to this for receiving the same thanks/badge? I was able to create this successfully, we just don’t want a salesperson to be able to have more than certain badge during the fiscal year. Any ideas how we might be able to build this.

    I have tried limiting per user on the badge creation area, but this process still triggers even with the limit.

    1. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

      Before giving the badge to anyone, you have to put additional logic. Check the badge count. If it is under the limit, then give the current budget; else, do nothing.

    1. Rakesh Gupta – Mumbai – 9x Salesforce MVP | Senior Solution Architect | 8x Author | 5x Dreamforce Speaker | Salesforce Coach | Co-host of AutomationHour.com and AppXchangeHour.Com

      Yes, they are bulkified

  3. Hi Rakesh,

    Nice Tutorial. Do you have an idea on further how to measure these badges. Suppose an Sales rep got 10 Badges and we want to promote him to next Badge? Can we create a report on these Badges?

    Regards,
    Asmita

    1. I think yes you shout able to create a report in badges.

  4. I followed the instruction to the word.

    When testing the flow:

    An unhandled fault has occurred in this flow

    When trying to change opportunity status from Negotiation to Closed WOn

    The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID ###############. Contact your administrator for help.

    Please help.!!

        1. You can add Thanks in Chatter even without a work.com license. To Enable Chatter Thanks, from Setup, enter Work.com Settings in the Quick Find box, then select Work.com Settings and select Enable.

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Automation Champion

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%