Skip to main content
Add note about correct api version
Source Link
Kai Tribble
  • 335
  • 3
  • 13

Note: this works for api version 44.0

Turns out there's a trick to doing this with the Metadata API

 <types> <members>Support</members> <name>Profile</name> </types> 
 <types> <members>Support</members> <name>Profile</name> </types> 
 <types> <members>Account.Custom_Record_Type</members> ... <members>Task.Custom_Record_Type</members> <name>RecordType</name> </types> <types> <members>Account</members> ... <members>Task</members> <name>CustomObject</name> </types> 
 <types> <members>Account.Custom_Record_Type</members> ... <members>Task.Custom_Record_Type</members> <name>RecordType</name> </types> <types> <members>Account</members> ... <members>Task</members> <name>CustomObject</name> </types> 
 ... <objectPermissions> <allowCreate>true</allowCreate> <allowDelete>false</allowDelete> <allowEdit>false</allowEdit> <allowRead>true</allowRead> <modifyAllRecords>false</modifyAllRecords> <object>Account</object> <viewAllRecords>true</viewAllRecords> </objectPermissions> <recordTypeVisibilities> <default>false</default> <recordType>Account.Custom_Record_Types</recordType> <visible>false</visible> </recordTypeVisibilities> ... <recordTypeVisibilities> <default>false</default> <recordType>Task.Custom_Record_Type</recordType> <visible>false</visible> </recordTypeVisibilities> ... <tabVisibilities> <tab>standard-Account</tab> <visibility>DefaultOn</visibility> </tabVisibilities> ... <userPermissions> <enabled>true</enabled> <name>ViewRoles</name> </userPermissions> </Profile> 
 ... <objectPermissions> <allowCreate>true</allowCreate> <allowDelete>false</allowDelete> <allowEdit>false</allowEdit> <allowRead>true</allowRead> <modifyAllRecords>false</modifyAllRecords> <object>Account</object> <viewAllRecords>true</viewAllRecords> </objectPermissions> <recordTypeVisibilities> <default>false</default> <recordType>Account.Custom_Record_Types</recordType> <visible>false</visible> </recordTypeVisibilities> ... <recordTypeVisibilities> <default>false</default> <recordType>Task.Custom_Record_Type</recordType> <visible>false</visible> </recordTypeVisibilities> ... <tabVisibilities> <tab>standard-Account</tab> <visibility>DefaultOn</visibility> </tabVisibilities> ... <userPermissions> <enabled>true</enabled> <name>ViewRoles</name> </userPermissions> </Profile> 

Turns out there's a trick to doing this with the Metadata API

 <types> <members>Support</members> <name>Profile</name> </types> 
 <types> <members>Account.Custom_Record_Type</members> ... <members>Task.Custom_Record_Type</members> <name>RecordType</name> </types> <types> <members>Account</members> ... <members>Task</members> <name>CustomObject</name> </types> 
 ... <objectPermissions> <allowCreate>true</allowCreate> <allowDelete>false</allowDelete> <allowEdit>false</allowEdit> <allowRead>true</allowRead> <modifyAllRecords>false</modifyAllRecords> <object>Account</object> <viewAllRecords>true</viewAllRecords> </objectPermissions> <recordTypeVisibilities> <default>false</default> <recordType>Account.Custom_Record_Types</recordType> <visible>false</visible> </recordTypeVisibilities> ... <recordTypeVisibilities> <default>false</default> <recordType>Task.Custom_Record_Type</recordType> <visible>false</visible> </recordTypeVisibilities> ... <tabVisibilities> <tab>standard-Account</tab> <visibility>DefaultOn</visibility> </tabVisibilities> ... <userPermissions> <enabled>true</enabled> <name>ViewRoles</name> </userPermissions> </Profile> 

Note: this works for api version 44.0

Turns out there's a trick to doing this with the Metadata API

 <types> <members>Support</members> <name>Profile</name> </types> 
 <types> <members>Account.Custom_Record_Type</members> ... <members>Task.Custom_Record_Type</members> <name>RecordType</name> </types> <types> <members>Account</members> ... <members>Task</members> <name>CustomObject</name> </types> 
 ... <objectPermissions> <allowCreate>true</allowCreate> <allowDelete>false</allowDelete> <allowEdit>false</allowEdit> <allowRead>true</allowRead> <modifyAllRecords>false</modifyAllRecords> <object>Account</object> <viewAllRecords>true</viewAllRecords> </objectPermissions> <recordTypeVisibilities> <default>false</default> <recordType>Account.Custom_Record_Types</recordType> <visible>false</visible> </recordTypeVisibilities> ... <recordTypeVisibilities> <default>false</default> <recordType>Task.Custom_Record_Type</recordType> <visible>false</visible> </recordTypeVisibilities> ... <tabVisibilities> <tab>standard-Account</tab> <visibility>DefaultOn</visibility> </tabVisibilities> ... <userPermissions> <enabled>true</enabled> <name>ViewRoles</name> </userPermissions> </Profile> 
Source Link
Kai Tribble
  • 335
  • 3
  • 13

Turns out there's a trick to doing this with the Metadata API

If your package.xml file only contains

 <types> <members>Support</members> <name>Profile</name> </types> 

Then it only retrieves user permissions, license information and whether or not it's custom. My best guess is because of the dependencies on the other metadata.

With that being said, simply add the remaining metadata components you're looking to retrieve that are related to the profile to the package.xml file:

 <types> <members>Account.Custom_Record_Type</members> ... <members>Task.Custom_Record_Type</members> <name>RecordType</name> </types> <types> <members>Account</members> ... <members>Task</members> <name>CustomObject</name> </types> 

And the result of your profile metadata api retrieval will look like this:

 ... <objectPermissions> <allowCreate>true</allowCreate> <allowDelete>false</allowDelete> <allowEdit>false</allowEdit> <allowRead>true</allowRead> <modifyAllRecords>false</modifyAllRecords> <object>Account</object> <viewAllRecords>true</viewAllRecords> </objectPermissions> <recordTypeVisibilities> <default>false</default> <recordType>Account.Custom_Record_Types</recordType> <visible>false</visible> </recordTypeVisibilities> ... <recordTypeVisibilities> <default>false</default> <recordType>Task.Custom_Record_Type</recordType> <visible>false</visible> </recordTypeVisibilities> ... <tabVisibilities> <tab>standard-Account</tab> <visibility>DefaultOn</visibility> </tabVisibilities> ... <userPermissions> <enabled>true</enabled> <name>ViewRoles</name> </userPermissions> </Profile> 

All of the steps in how to do this are listed here in this article.