Friday 21 February 2014

Mass Assigning Permission Sets via the API using Workbench




The most efficient way to assign multiple users a permission set at once is through the API with Workbench. Workbench is a powerful, web­based suite of tools designed for System Administrators and developers to manage data within Salesforce orgs via the Force.com APIs.


In order to mass assign a permission set to a group of users, two pieces of information are required; the permission set ID and the user IDs of the users you wish to assign it to. The steps below will outline how to gather this information and create the .csv file you will use to mass assign your permission sets.


To access Workbench, log into your Work.com on Salesforce Org. Paste this URL into your open browser window: https://workbench.developerforce.com/login.php


Download a .csv of your User ID’s by running the query below. 1. Choose SOQL Query in the Jump to drop down menu

2. Choose User in the Object drop down menu
3. Click Select
4. In the Fields section, highlight both ID and Name
5. Select the Bulk CSV radio button
6. Click Query

7. Click on the download symbol to download the .csv


The headers of the .csv will include: ID and Name



8. Click on the download to open the file and Save As User.csv” to your desktop


Find the ID of the permission set to be assigned

1. From Setup choose Manage Users | Permission Sets | <Name of Permission Set> a. Find the number following the last forward slash (/) in the url. e.g if the url is
https://na8.salesforce.com/0PSC0000000KQdP then 0PSC0000000KQdP is the ID of the permission set.
2. Copy this ID as you will add it to the .csv in the next step


Modify the .csv for upload




1. In the User.csv file, find the users you would like to assign the permission set to, and delete the other rows
2. Delete all the data in the Name column

3. Rename the header of the Name column to PermissionSetId 4. Rename the ID column to AssingeeId
5. Add the Permission Set ID that you copied in the previous steps and paste into all of the rows uner the PermissionSetId header


Your .csv file should look similar to this:


Upload the .csv to assign the permission set 1. From the Data menu in workbench select Insert

2. Choose PermissionSetAssignment in the Object Type drop down menu 3. Select the From File radio button
4. Select Choose File and find the User.csv file you saved to your desktop

 . Once you have selected the file to upload, click Next



You will then be directed to the following page:



 
6. Click Map Fields

. Click Confirm Insert


An Insert Successful message will be displayed


Confirm the Permission Set has been assigned to a user on the User Detail Page.
1. From Setup choose Manage Users | Users| <Name of User>

2. Navigate to the Permission Set Assigned Related list to confirm it has been assigned correctly

No comments:

Post a Comment