Skip to main content

Dear fellow trailblazers,

 

I recently came across a simple request to retrieve admin profile to my repo from an org that contains the right object permission I would like to deploy elsewhere.

 

After running the following cli command:

sfdx force:source:retrieve -m Profile:Admin -u abc

 

The profile is retrieved but only has userPermissions, everything else are missing including objectPermissions.

 

I did a quick online research, everything's pointing to updating package.xml, which I don't have it in my project repo, for example:

<?xml version="1.0" encoding="UTF-8"?>

<Package xmlns="http://soap.sforce.com/2006/04/metadata">

<types>

<members>Account.MyCustomField__c</members>

<name>CustomField</name>

</types>

<types>

<members>*</members>

<name>Profile</name>

</types>

<version>53.0</version>

</Package>

Since my company repo doesn't have package.xml so no point going down this direction.

 

Could anyone help me understand what is missing here?

 

Thank  you in advance!

 

Cheers

Dale

 

#SFDX CLI #Profile Permissions #Profiles #Salesforce DX #Salesforce Developer #Sfdx #Sfdx Command

6 respuestas
  1. 24 ene 2024, 11:00

    This might be very late to answer. However, adding my comment in case if someone needs this. 

     

    If you don't have a package.xml, alternatively you can use below command where you can specify the components that you want to retrieve.

     

    sfdx force:source:retrieve -m "Profile,CustomObject"

    Note that in the last parameter of this command, we specify the metadata components. In your case @Dale Wang you need to specify "CustomObject" along with "Profile" as already answered by @Kishan Kumar. If you do not specify "CustomObject", for all the profiles retrieved only "UserPermissions" will be fetched.

     

    However, note that whenever we retrieve profiles using this approach or by using package.xml, the SFDX command does not retrieve all the permissions. Only the permissions where access is explicitly given will be fetched. E.g. for a profile, if object permission - Read is given for object CustomObject1__c and no permission is given on CustomObject2__c, even if you specify both objects in the package.xml or the command parameters, it will retrieve object permissions for CustomObject1__c only as it finds the <allowRead> attribute as TRUE in Salesforce.

0/9000