5

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

9

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

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.