In the source org, Permission Sets had various users assigned to them. After deployment, Permission Sets in the destination org had no users in them.

All of the users are in both orgs with the same IDs.

How can I deploy user assignments along with the permission sets?

  • 3
    I don't think any of the deployment tools would let you do that. I think you would need a 2 stage approach of deploy the Permission sets then see if another tool like Data Loader allowed you to assign the users to those permission sets.
    – Dave Humm
    Commented Oct 31, 2016 at 21:27

1 Answer 1


Permission Set Assignments are data in the org. The DML operation cannot be performed by a Change Set - but this sample code might help you in automating the assignments.

// the user reference
User u = new User();

// the names of the permission sets you need to assign
List<String> permissionSets = new List<String>{'permission_set_name_1','permission_set_name_2'};

// the assignment records for DML
List<PermissionSetAssignment> psAssignments = new List<PermissionSetAssignment>();

// query for the sets and assign to the user
for (PermissionSet ps : [SELECT Id, Name
                           FROM PermissionSet
                          WHERE Name IN :permissionSets]) {
        new PermissionSetAssignment(
            AssigneeId      = u.Id,
            PermissionSetId = ps.Id

// insert the assignments
insert psAssignments;
  • Thanks. I am seeing the same behavior for the Group object. Groups themselves came over, but the users from the groups did not. Marking as the answer. Commented Nov 1, 2016 at 12:50

You must log in to answer this question.

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