You need to sign in to do that
Don't have an account?
Kellymt
How to find the layout assigned to a particular user from Apex?
Does anybody know how can I find the layout assigned to a particular user from Apex?
I know that the Metadata API will give me that information:
MetadataService.Profile profile = (MetadataService.Profile)service.readMetadata('Profile', new String[] { profileName }).getRecords()[0];
for(MetadataService.ProfileLayoutAssignment layoutAssignment : profile.layoutAssignments) {
if(layoutAssignment.layout.startsWith('Account')) {
accountLayoutName = layoutAssignment.layout;
break;
}
}
but the metadata API is not available from within Apex and using the MetadataService provided by FinancialForce.com (great job guys) seems like an overkill to me.
Also does anybody know if the MetadataAPI counts towards your API call limits?
Thanks,
Kzmp
I know that the Metadata API will give me that information:
MetadataService.Profile profile = (MetadataService.Profile)service.readMetadata('Profile', new String[] { profileName }).getRecords()[0];
for(MetadataService.ProfileLayoutAssignment layoutAssignment : profile.layoutAssignments) {
if(layoutAssignment.layout.startsWith('Account')) {
accountLayoutName = layoutAssignment.layout;
break;
}
}
but the metadata API is not available from within Apex and using the MetadataService provided by FinancialForce.com (great job guys) seems like an overkill to me.
Also does anybody know if the MetadataAPI counts towards your API call limits?
Thanks,
Kzmp
You Apex supports SOQL queries. You could try something like this:
SELECT ProfileId, Username, Profile.Name
FROM User
WHERE ID = '005o0000000FuCt'
Chris
Thank you for your response.
I am able to query the profile but I am not able to find out how to find the layout assignments via SOQL. Do you have an idea how to do that?
Kzmp