You need to sign in to do that
Don't have an account?
Daniel Retaleato
How can I get the name of the current app in the Apex Controller?
I need to get the name of the current app in the controller. So far I'm trying:
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!
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!
Greetings to you!
Your code looks good to me. Make sure you are using API version 43.0 or later. As per the Salesforce doc, AppDefinitionId field on UserAppInfo object and AppDefinition object are available in API version 43.0 and later.
Please refer to the below links which might help you further.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_userappinfo.htm
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_appdefinition.htm
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
All Answers
Greetings to you!
Your code looks good to me. Make sure you are using API version 43.0 or later. As per the Salesforce doc, AppDefinitionId field on UserAppInfo object and AppDefinition object are available in API version 43.0 and later.
Please refer to the below links which might help you further.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_userappinfo.htm
https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/sforce_api_objects_appdefinition.htm
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
I beleive the issue is with version