Automation, Trailhead

Customizing Trailhead Tracker With Process Builder


Salesforce recently released an Appexchange package called Trailhead Tracker which syncs your user’s Trailhead activity into your Salesforce org.  The app has several features including the ability to assign specific modules to your users and track badge completion progress.  The package even includes a set of reports and a dashboard that nicely summarizes the assigned, in progress, and completed badge activity.  Admins interested in using Trailhead as part of their user training and on-boarding strategy should really look into the features of this tool!  

The reports and dashboards included with Trailhead Tracker provide a lot of useful information about user engagement, yet the module lack any specific collaboration features. If we could combine the collaboration features of Chatter with the data from Trailhead Tracker, it would be possible to create a Chatter post each time a user completes a Trailhead badge.  Creating a Chatter post announcing the completion of a Trailhead badge adds an element of gamification to the training process and provides a forum to discuss questions related to specific badges.

Adding Chatter to Trailhead Tracker with Process Builder

The Trailhead Tracker package includes a custom object named User Badge which contains records for each Trailhead badge that has been assigned, started, or completed by users in your org. The records in this object are updated during the daily sync period between your org and Trailhead. We can use Process Builder to monitor changes in the User Badge records and look for entries which are created with, or changed to have, a status value of ‘Completed’.  Using the ‘Immediate Actions’ feature of process builder, it is possible to post a plain-text message to Chatter and recognize the user for earning the badge.

Building the Process

  1. Launch Process Builder and create a new process:
  2. Enter values for the Process Name and Description fields.
  3. Use the option ‘A record changes’ to specify what events will cause this process to start.
  4. Click “Save” to continue.

New Process Builder Screen

  1. Configure the process to start when a User Badge record is created or edited.
    • Click the ‘Add Object’ element and select the ‘User Badge’ object from the list.
    • Specify to start the process ‘when a record is created or edited’.
    • Click the Save buttonProcess Builder - Starting Object
  1. Configure the criteria for creating the Chatter post.  In this case, we only want to create a Chatter post when a record has a status of “Completed” when created or if an existing record status changes to “Completed”.
    • Criteria Name: Completed User Badge
    • Criteria for Executing: Conditions are met
    • Condition:
      • Field Name: [trailheadapp__User_Badge__c].trailheadapp__Status__c
      • Operator: Equals
      • Type: String
      • Value: Completed
    • Conditions: Any of the conditions are met
    • Advanced: Expand and check ‘Yes’
    • Click SaveCompleted User Badge Criteria
  1. Define the values needed to create a Chatter post.   Click the ‘Add Actions’ button under ‘Immediate Actions’ and configure the values as indicated below. This example will post the Chatter messages to a Chatter group but you could configure it to post directly to the User Feed.
    • Action Type: Post to Chatter
    • Action Name: Post Notification Message
    • Post To: Chatter Group
    • Group: Trailhead User Group – Be sure to specify a group which exists in your org
    • Message: Use the merge field lookup tool to include values from fields related to the User Badge record.  This example includes the first and last name of the user along with the name of the badge which was completed. 
  “{![trailheadapp__User_Badge__c].trailheadapp__User__r.FirstName} {![trailheadapp__User_Badge__c].trailheadapp__User__r.LastName} has earned the {![trailheadapp__User_Badge__c].trailheadapp__Badge__r.Name} on Trailhead!”
  • Click Save to continue.Post to Chatter Message
  1. Activate the process!  Activate Process Confirmation Message

See the process in action

The Trailhead Tracker app syncs users data with Trailhead once a day. To see this process in action you could wait until the next sync time and then review the Chatter feed. Alternatively, you could consider one of the following options to , however, there are a few options available to test the new process without waiting until the next scheduled sync time.

  1. Manually create a completed “User Badge” record with the status of ‘Completed’.
    • Badges created with a status value of ‘Completed’ will trigger the process to create the Chatter post.
    • Note that you will need to supply a dummy value for the External Id field on the User Badge record in order to save the test record.
    • Once you have confirmed proper operation of the process you should delete the test record to ensure your user badge date is accurate.
  2. Complete a badge in Trailhead and then manually force Trailhead Tracker to sync your Trailhead data to your org.  
    • Open Developer Console
    • Click the Debug menu and select ‘Open Execute Anonymous Window’
    • Enter the following code
    • Click Execute
trailheadapp.ScheduledDispatcher s = new trailheadapp.ScheduledDispatcher();

Developer Console - Execute Anonymous

In either of the cases above, the activated process should create a Chatter message in the Chatter group. The Chatter message should look something like the screenshot shown here.

Badge Completion Chatter Post



As you can see, creating a single element process with a Post to Chatter action allows you to combine the collaboration features of Chatter with the badge completion data in Trailhead Tracker. In Part II of this topic, we will look at how to leverage Apex to create a rich-text Chatter post which will include more formatting and the icon associated with the completed badge.

Have questions or comments on this article — reach me on Twitter @SFDCAdvocate