Salesforce: How to get app name for current logged in user in salesforce lightning

 We have option to get app name for current loggedin user in salesforce lightning. If we have to know that from which app current user is invoking the transaction. You can refer the below code to get the app name.

UserAppInfo userAppInfo = [SELECT Id, AppDefinitionId FROM UserAppInfo WHERE UserId = :UserInfo.getUserId() Limit 1];

 AppDefinition appDefinition = [SELECT DurableId, Label FROM AppDefinition Where DurableId = :userAppInfo.AppDefinitionId Limit 1];

 System.debug('App Name....+'appDefinition.Label);


Comments