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:
- UserAppInfo (Label: Last Used App)
- 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'