1

I need to get the name of the current app in the controller. So far I'm trying:

public static String getAppName() {

       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;
    }

But Im getting 3 errors:

Line 1: No such column 'AppDefinitionId' on entity 'UserAppInfo'
Line 2: Invalid type: AppDefinition
Line 3: Variable does not exist: appDefinition

Can anyone provide some insight as to what I may be doing wrong? Thanks!

2

Check the API version of your class. AppDefinition is only available in 38.0 or greater, and the AppDefinitionId field is only available in 43.0 or greater. The code you provided works as an execute anonymous script, so I presume it's simply a version problem.

  • And UserAppInfo.AppDefinitionId requires v43.0 or greater. – Thomas Taylor Apr 8 at 14:44
  • 1
    @ThomasTaylor Ah, that wasn't in the docs I checked. I'll update. – sfdcfox Apr 8 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.