0

I want to retrieve the apex class security using ANT/ workbench.

What I need to define in the package.xml to retrieve the apex class security.

Apex security

Profiles




please let me how I can retrieve this metadata.

1

1 Answer 1

4

Apex class security is defined as a part of the profile or permission set XML file and would be something like as shown below (after retrieval):

...
<classAccesses>
      <apexClass>CustomApexClassName</apexClass>
      <enabled>true</enabled>
</classAccesses>
...

So, all you need to do is to specify the required apex class names and the profile names in your package.xml file. Something like the snippet shown below:

...
<types>
    <members>CustomApexClassName</members>
    <name>ApexClass</name>
</types>
<types>
    <members>MyProfileName</members>
    <name>Profile</name>
</types>
...

Note that just specifying the profile alone in the package.xml will not work. Specify the appropriate the apex class and profile names in the package.xml (the snippets above show the placeholder names)

You may refer the Metadata API developer guide here & here. Security settings for all of the components list below are retrieved as a part of profile or permission set file.

In API version 29.0 and later, you can retrieve and deploy access settings for the following managed components in profiles and permission sets:

  • Apex classes
  • Apps
  • Custom field permissions
  • Custom object permissions
  • Custom tab settings
  • External data sources
  • Record types
  • Visualforce pages
2
  • Thank you for answering and adding the documentation link.
    – ABHIN B.T
    Nov 20, 2020 at 11:07
  • There will be some other standard tags like custom, userLicense, userPermissions etc, but those can be ignored. But yes class name and profile both are mandatory. Also for bulk retrieval keep all class and profile nodes, or add wild character <types> <members>*</members> <name>ApexClasses</name> </types> Nov 20, 2020 at 11:09

You must log in to answer this question.

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