[SalesForce] retrieve a Profile’s XML with Managed Package metadata

I am currently attempting to update a new profile's permissions to match that of another profile (different license types, so cloning isn't available).

My current best solution is to pull various metadata types through SFDX along with the old and new profiles, copy the xml from the old profile to the new, and redeploy.

Only problem is, when I retrieve CustomObject and CustomField metadata, it only includes unpackaged objects/fields. I have a large managed package with many objects and customized levels of CRUD permissions, and I'm looking to update CRUD and FLS for those packaged objects and fields.

Is there a way to get managed package objects/fields in the profile metadata as well?

Here is my current package.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>*</members>
        <name>CustomField</name>
    </types>
    <types>
        <members>*</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>Commercial Lending Manager</members>
        <members>Loan Closing</members>
        <name>Profile</name>
    </types>
    <version>41.0</version>
</Package>

Best Answer

Yes, you can

DISCLAIMER :I am the author of the below mentioned module.

I had the similar problem few weeks ago and am able to resolve it using below module.

Hope this answer finds you. In case you are still looking for it.There a CLI which has a capability to retrive full profile xml along with CRUD and FLS. Written as a node module.Here are steps.

NOTE: this is a wrapper module which internally uses sfdx cli.

  1. Install Node.js

if you dont already have.

  1. Type in node -v . to confirm you have it working .

  2. Run npm install -g mydxcli

  3. From Folder of your choice run the command.

mydxcli -u Myusername -getProfile "Profile1,Profile2" --getPermissionSet "PS1,PS2"

--username or -u : You org's username or alias name Required

--getProfile or -gP : Specify profile names you want to retrieve
optional : if value is not specified , it will fetch all profiles in org

--getPermissionSet or -gPs : Specify PermissionSet names you want to retrieve
optional : if value is not specified , it will fetch all PermissionSets in org

--directory -d : The Directory where you want to retrieve the files
if not specified default folder will be mydxcli

--help // Fetches available options

Module Link: mydxcli

What the Module does internally :

  1. Gets the List of class,pages,custom objects using mdapi:listmetadata
  2. Dynamically generates package.xml based on it.
  3. performs mdapi:retrieve to specified folder and the profile now retrieved contains all desired values.
Related Topic