Capture the name of the App where a record was created

Last Updated on November 17, 2023 by Sudhir

Background

One of my clients asked me if there is a way to track which application the user was in when they created an Account record. The client did not have Event Monitoring. 

The thought was to store the application name where the user was at the time they created the account, on the account itself. But this storage can also be done in a more centralized location such as a custom object and be extended to more than just account object records. Whether we store the information on the record, or in a centralized location, the approach to get the application information would be the same using the two objects mentioned below.

The queries can be run in Apex trigger/LWC, or using Flow.

Use the following objects, in this order:

  1. UserAppInfo (Label: Last Used App)
  2. AppDefinition (Label: App Definition)

Sample Queries:

Query UserApInfo filtering for User ID first:

SELECT AppDefinitionId, UserId, Id FROM UserAppInfo where UserId='0052g0000023kgaAAA'

Take the AppDefinitionId and filter AppDefinition where DurableId=AppDefinitionId:

SELECT Id, DurableId, Label, MasterLabel, DeveloperName FROM AppDefinition Where DurableId='06md0000000bp06AAA'

Sample Flow

Author: Sudhir

I am a Salesforce Certified Application Architect. My passion is to enable my clients to realize their goal of deploying enterprise-wide Salesforce solutions to alleviate their pain points and help them realize efficiencies, be it of scale or in day-to-day tasks.