amtrack / force-dev-tool

[DEPRECATED] Command line tool supporting the Force.com development lifecycle
MIT License
108 stars 37 forks source link

PermissinSet sync #89

Closed vkolotov closed 5 years ago

vkolotov commented 7 years ago

Hi @amtrack,

I'm trying to set up a CI environment which deploys changes from git to salesforce. I've got some bash scripts which generate changesets and then deploy them to salesforce. However, I came across an issue with PermissionSet metadata. When I try to deploy incremental changes which include some changes in PermissionSets, I get this:

Error: Deployment with RunSpecifiedTests option failed.
 - Error in PermissionSet component 'Bulk_Send_Notifications': Required field is missing: label

I've started to troubleshoot and noticed that force-dev-tool generates some files under config/deployments//permissionsets. For some strange reason the files under permissionsets folder are not the same as in "src" folder, e.g. they contain only a fraction of data (presumably just changes):

Bulk_Send_Notifications.permissionset file:

<?xml version="1.0" encoding="UTF-8"?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
    <fieldPermissions>
      <editable>false</editable>
      <field>CITestObject__c.TestField__c</field>
      <readable>false</readable>
    </fieldPermissions>
</PermissionSet>

Whereas its counterpart under src folder is a lot bigger, it also includes <label> tag as well.

So the question is, why does force-dev-tool not just copy files from src to changeset folder? How to make force-dev-tool to copy entire files? I would assume that if you deploy a changeset you should have a FULL file which you have imported from salesforce, otherwise if you deploy just a part of that file, salesforce will remove/delete missing parts in the org.

Thanks, Vlad

amtrack commented 7 years ago

Hi @vkolotov, thanks for reporting! You are right, the label element is missing indeed. According to the documentation the label is required. I thought that PermissionSet can be treated the same way as Profile which was a wrong assumption. I will provide a fix once i figured out a good solution. EDIT: keep this in mind: https://twitter.com/FabienTaillon/status/850087152033701888

However i disagree on the approach to deploy a FULL file. To understand my point of view, i suggest you create a Changeset in the Salesforce Setup Interface yourself, add a Permission Set together with a Visualforce Page (for example). If you upload the Changeset to another org and click on View Source for the Permission Set you'll see that only elements of the Permission Set itself (such as label), the userPermissions elements and further only elements of components you included in the Changeset (here pageAccesses for the Visualforce Page) will be contained in the file.

Salesforce usually doesn't delete anything due to absence. You'll have to specify a destructiveChanges.xml file in the deployment to delete something, see here.

However if you still want to deploy the full PermissionSet, you can create a changeset with force-dev-tool the following way:

$ force-dev-tool changeset create my-permission-set PermissionSet/MyPermissionSet

Again, thanks for reporting, and i'm happy to see more issues being reported like this!

vkolotov commented 7 years ago

Hi @amtrack, sounds good. Looking forward to seeing the fix.

okram999 commented 7 years ago

hi @amtrack this is a kind of show stopper :( ... is there a quick fix for this? i generate the package xml using diff and ues that in the same flow to deploy, now with the labels missing in the permissionsets.. the deployment fails.

froucher commented 5 years ago

Hello, I want to ask if someone is working in a solution for this bug. If not, I will try to investigate if I can create a pull request, but not sure if I will be able...

amtrack commented 5 years ago

@froucher I'm looking into it now.

amtrack commented 5 years ago

:tada: This issue has been resolved in version 2.4.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

froucher commented 5 years ago

:clap::clap::clap: