Assign License and Permission Set on Team Member Addition

Managed Package Licenses are required for users to have access to Distribution Engine tabs and fields and for Auto-Action to occur. These steps will allow you to create a process builder flow that will add a managed package license when a user is added to a team.  Any user who needs access to the functionality of Distribution Engine will need a Permission Set.

This is a three part process that starts with Creating a Custom Label, then Creating a Flow, and then Creating a Process Builder process. 

Creating the Custom Label

The first step in the process will be to capture the Permission Set ID for the Distribution Engine User permission set and assign it to a Custom Label. 

1). Open the Developer Console by clicking on your name in the upper right and selecting Developer Console from the dropdown.

2) In the Query Editor tab enter the following text "Select id, Name from PermissionSet where Label= 'Distribution Engine User' and select Execute.

3) This is the ID you will need for your Custom Label to use in the flow. Be sure to copy this ID. In our example, the ID is 0PS1r000001CA4GGAW

4) Now we will create a custom label - Navigate to Setup and search for Custom Labels.

5) Name your Custom Label "Distribution Engine User" and place your ID in the value section and select Save.

Creating the Flow

The first step in the process will be to create the flow that will be used in your process builder. This flow will lookup the Distribution Engine package License ID, verify if the user already has a license, and assign if they do not. 

Images can be clicked on to enlarge

1) Navigate to the Flows section by going to Setup and searching for Flows

2) Create a New Flow, Navigate to the Resources tab, and double click the Variable option. 

3) We will create 3 varialbes. One will hold the Distribution Engine License Id, one will hold the UserId passed from your process builder, and one will be used to determine if the user has a license already.




4) Navigate back to the Palette tab and drag and drop the Record Lookup data step to your design canvas.

5) The first Record Lookup will be to get the Managed Package License ID. 

  • Choose a name for this step
  • Set the Look up object to PackageLicense
  • Set the Field Criteria to be NamespacePrefix equals n2de
  • Assign the Id field to the n2de_PackageLicenseID variable previously created

6) Drag a second Record Lookup data step to your canvas. This one will be used to determine if the user already has a license.

  • Choose a name for this step 
  • Set the Look up object to UserPackageLicense
  • Set the Field Criteria: 
    • PackageLicenseId equals n2de_PackageLicenseID
    • UserId equals n2de_UserID
  • Assign the Id field to the has_license variable previously created
  • Check the "Assign null values to the variable(s) if no records are found" option.



7) Drag and drop a Decision logic step to your canvas. 

8) Configure the decision.

  • The first outcome will be "Yes" and will look at the has_license variable to see if it does not equal null (value is left blank.)  
  • The default outcome can be named "No" and will be the default outcome if the user does not have a license already assigned to them

9) Drag and drop a Record Create step to your canvas:

10) Configure the Record Create step:

  • Choose a name for this step
  • Set the Create object to UserPackageLicense
  • Set the field values we'll be setting:
    • Field: PackageLicenseId     Value: n2de_PackageLicenseID
    • Field: UserId     Value: n2de_UserID

11) Create a Formula for your PermissionSetID by selecting the Resources tab and clicking Forumula

12) Set the criteria for your formula 

  • Name - we have used PermissionSetID
  • Value Data Type = Text
  • Select Resource > System and Global Variences > $Label > Distribution_Engine_User > Ok

13) Drag and drop the Record Create to your flow window

  • Name - we used Add Permission Set
  • Create - PermissionSetAsssignment
  • Feild Values 
    • AssigneeId = [n2de_UserD}
    • PermissionSetID = {PermissionSetId}

14) Link everything together

  • Make sure the first step (Record Lookup DE Managed License ID) is marked as the starting element
  • Make sure to choose the "No" action (Default Outcome previously named No) when linking the Decision to your Record Create


15) Save your flow and activate it


Create the Process Builder process

Once you have the flow created, you'll need to tie this in to a Process Builder process. 

Images can be clicked on to enlarge

1)  Navigate to Setup / Process Builder

2) Create a New process builder process

  • Set the process to start when a record changes


3) Click the + Add Object section and choose the object to start the process

  • The object is Distribution team member
  • only when a record is created should be selected for when to start the process

4) Click the + Add Criteria option

  • Name the critera anything you'd like
  • Set the Criteria for Executing Actions to No criteria-just exxecctue the actions!


5) We're going to create this as a Scheduled Action due to certain update types not being able to occur at the same time.

  • Click Set Schedule
    • Set to 0 days after CreatedDate

  • Click +Add Action in the Scheduled Action section
    • Action Type = Flows
    • Name the action anything you'd like
    • Flow = The flow you created in the first part of this tutorial (a drop down is provided)
    • Set Flow Variables
      • Click + Add Row
        • Flow variable = n2de_UserID created in the first part of this tutorial
        • Type = Field Reference
        • Value = selecct n2de__User__c 


6) Save the action and Activate the process

It may take a few minutes before the license is actually assigned to the user as this is done as a scheduled action. 


How did we do?

Rejection API Process

Assign License on Team Member Addition