4

I want to access the Standard "System Administrator" profile using MetadataService.cls (found here https://github.com/financialforcedev/apex-mdapi)

Therefore I tried this

MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();

MetadataService.Profile profile 
 = ( MetadataService.Profile) service.readMetadata(
       'Profile', 
       new String[] { 'System Administrator'}
   ).getRecords()[0];               

Unfortunately profile is not populated by the readMetadata-method. It behaves exactly like a non-existing profile.

How the profile can be read?

1 Answer 1

8

The issue is the name of the profile.

Using exclipse downloading all profiles, I found that there is an "Admin" profile instead. Reading this the same way as described above, it works.

MetadataService.Profile profile 
 = ( MetadataService.Profile) service.readMetadata(
      'Profile', 
      new String[] { 'Admin' }
   ).getRecords()[0];

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .