+ Start a Discussion
Praveen G 43Praveen G 43 

How can I get the name of the current app using Apex Code

Hi, I have tried the below code, but for me, it returns only the Same application name even though I tried executing from a different application. Can someone help with this?

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]; 
return appDefinition.Label;
AbhinavAbhinav (Salesforce Developers) 
Check this:


ravi soniravi soni
hi ,
SELECT Id, Name, Label FROM AppMenuItem
by running above query you will get all the apps name and if you want to get particular name then use where and give app name.

don't forget to mark it as best answer if it helps you.
thank you