I ran into an issue this week with attempting to deploy a permission set
that required the Read Document permission, and I'm wondering if
IlluminatedCloud or any of its users have encountered this or have an
approach or workaround I could adopt. Some quick background...
When you request profile
metadata, Salesforce only returns permissions related to the objects
included in package.xml used for the request. For example, retrieving
metadata using the following package.xml will result in the permission
set containing mostly metadata around SomeObject__c:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<!-- custom objects -->
<types>
<name>CustomObject</name>
<members>SomeObject__c</members>
</types>
<!-- permission sets -->
<types>
<name>PermissionSet</name>
<members>SomePermissionSet</members>
</types>
<version>37.0</version>
</Package>
The file structure you would have returned looks like this:
/src/objects/SomeObject__c.object
/src/permissionsets/SomePermissionSet.permissionset (contains info about SomeObject__c only)
If
the permission set requires some other permission (i.e. Read Account),
the normally the change is simple. Adding the object to the package.xml
and re-pulling metadata will return the appropriate chunks of the
permission set metadata, like so:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<!-- custom objects -->
<types>
<name>CustomObject</name>
<members>Account</members>
<members>SomeObject__c</members>
</types>
<!-- permission sets -->
<types>
<name>PermissionSet</name>
<members>SomePermissionSet</members>
</types>
<version>37.0</version>
</Package>
The file structure now looks like:
(contains info about Account and SomeObject__c)
With all that background, this becomes more complicated when using specifically the Document type, as
Document is not a retrievable metadata object:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<!-- custom objects -->
<types>
<name>CustomObject</name>
<members>Document</members>
<members>SomeObject__c</members>
</types>
<!-- permission sets -->
<types>
<name>PermissionSet</name>
<members>SomePermissionSet</members>
</types>
<version>37.0</version>
</Package>
The file structure now looks like:
(contains info about Document and SomeObject__c)
Importantly, the Document chunks of the permission set are properly returned from the MDAPI,
but Document.object metadata is not.
When you try to deploy using this package.xml, you will receive an
error indicating that Document.object is specified in the package.xml
but not present in the deploy package.
It seems like one
workaround might be to keep a separate "retrieve"
package.xml from a "deploy" package.xml, but that seems like a
maintenance nightmare for larger projects. The problem with this would
be that on-deploy, permission set and profile chunks related to entities
not present in the deploy package are ignored.
Any thoughts about how to attack this problem? Has anyone else here run into this issue before?