Thanks and Badges in Lightning Experience

As we all know there is a limitation with Thanks and Badges functionality in Lightning Experience. The idea has been created on Idea Exchange Platform and a part of it has been delivered by Salesforce.

In winter’19 Release, Salesforce has made the ability to Keep Members Engaged with Recognition Badges in Lightning Experience too as generally available. Also, As a pilot program, The ability to assign a badge to users in Lightning has been delivered. I have enabled it in my one of the Org and it is working in the same way as it was in classic. You will find the thanks action in the Chatter tab present at the navigation bar. You can enable the pilot program by working with your Support team, but still, Your user wants to see the badges they receive. How?

I have faced the same issue and end up with creating Aura Component to show the badges received by users.

Recognition in Lightning Experience

Let’s go through the code:

We have created the Aura Component named as BadgesGivenToMe.cmp and one apex controller called BadgesGivenToMeController.apxc.


In the below apex class, we are returning all the badges assigned to the current logged in user.

public class BadgesGivenToMeController {
     public static List getAllBadgesGivenToMe(){
        List workbdg =[SELECT Definition.Name, Message, ImageUrl, Giver.Name FROM WorkBadge
                                 where RecipientId=:UserInfo.getUserId()];
        return workbdg;

Note:- WorkBadge represents information about who the badge was given to and which badge was given. A WorkBadge record is created for each recipient of a WorkBadgeDefinition.

BadgesGivenToMe Aura Components

This Aura component has SLDS data table to show all the badges and use it on Home Page in Lightning Experience.

Find the Aura Component code on my GitHub repository:-

You can make amendments in the code and choose your desired fields to be shown on the table. The above solution will help you while migrating your traditional classic instance to Lightning Experience.

One comment

  1. Using the same code copy/paste, not making any changes, I do get an Unexpected ‘getAllBadgesGivenToMe’ error on the controller. I don’t typically do any sort of coding, so I’m at a loss on how this occurred. Any thoughts? Greatly appreciated, thank you. I can’t wait to be able to get this up in our instance.

Leave a Reply