Question
For the current user, how do you programmatically retrieve the FlexiPage layout (i.e. fields) for the default Opportunity record type?
What I've Tried
Since, the FlexiPage layout potentially depends on the user's profile and the app (e.g. Sales), my current approach is to retrieve the app's ActionOverride
and ProfileActionOverride
lists.
High Level Steps
- Get current user's profile:
SELECT FullName FROM Profile WHERE Id = '<profile_id>'
- Get all Opportunity FlexiPages:
SELECT Id, DeveloperName FROM FlexiPage Where EntityDefinitionId = 'Opportunity'
- Get Sales app
Metadata
:SELECT Metadata FROM CustomApplication WHERE Label = 'Sales'
- Check Sales app
ActionOverride
list fromMetadata
and see if there is a FlexiPage associated with Opportunity. - Check Sales app
ProfileActionOverride
list fromMetadata
and see if there is a FlexiPage associated with Opportunity and user's profile. - Get Opportunity FlexiPage from
ActionOverride
orProfileActionOverride
and retrieve FlexiPage layout.
Issue
Sometimes, the Sales app Metadata
contains an empty list for ActionOverride
and ProfileActionOverride
. In this scenario, how do you retrieve the FlexiPage layout (i.e. fields) for the default Opportunity record type?
ActionOverride
andProfileActionOverride
lists. There could be multiple record types defined for an Opportunity, but the default record type is used to retrieve the Lightning page layout.Layout
metadataType that is assigned to the default record type