How to use flow to auto-assign license and permission set to new users

In this article, you will learn how to create a flow that will automatically assign the Drive Connect License and Drive Connect Standard Permission when a user has been flipped to active.

Creating the flow

1. Flow Condition

  1. Create a record triggered flow
  2. Object – User
  3. Configure Trigger – A record is Created or Updated
  4. Entry Conditions – isActive Equals true
  5. When to run the flow for Updated Records – Only when a record is updated to meet the condition requirements
  6. Click Done

2. Add Get Records Element

  1. Add an element to the flow
  2. Choose the Get Records Element
  3. Label = Package License ID
  4. Object = Package License
  5. Filter By =  Namespace Prefix Equals driveconnect
  6. Sort Order = Not Sorted
  7. How Many Records to Store = Only the first record
  8. How to Store Record Data = Automatically store all fields 

3. Add Decision Tree for Package License

  1. Add an element to the flow
  2. Select Decision Tree
  3. Label – Does Package License Exist
  4. Outcome 1:
    1. Label = Package Exists
    2. Condition = {!Package_License_ID} isNull is false
    3. When to execute outcome = if the condition requirements are met
  5. Outcome 2 (Default outcome):
    1. Label = Does not exist

4. Create Drive Connect License Record

  1. Add an element to the Package Exists outcome
  2. Label = Assign Drive Connect License
  3. How Many Records to Create = One
  4. How to Set the Records Fields = Use separate resources, and literal values
  5. Object = User Package License
    1. Fields
      1. PackageLicenseId = {!Package_License_ID.Id}
      2. UserID = {!$Record.Id}

5. Add Get Records for Standard User Permission Set

  1. Add a Get Records element where the two outcomes meet
  2. Label = Standard User Permission Set
  3. Object = Permission Set
  4. Conditions = Name Equals Drive_Connect_Generate_Files
  5. Sort Order = Not Sorted
  6. How Many Records to Store = Only the first record
  7. How to Store Record Data = Automatically store all fields

6. Add Decision Tree for Permission Set

  1. Add an element to the flow
  2. Select Decision Tree
  3. Label = Does Permission Set Exist
  4. Outcome 1:
    1. Label = Permission Set Exists
    2. Condition = {!Standard_User_Permission_Set.Id} isNull is false
    3. When to execute outcome = if the condition requirements are met
  5. Outcome 2 (Default outcome):
    1. Label = Does not exist

7. Create Permission Set Record

  1. Add a Get Records element to the Permission Set Exists outcome
  2. Label = Assign Permission Set
  3. How Many Records to Create = One
  4. How to Set the Records Fields = Use separate resources, and literal values
  5. Object = Permission Set Assignment
    1. Fields
      1. PermissionSetId= {!Standard_User_Permission_Set.Id}
      2. AssigneeId = {!$Record.Id}

Now the flow is complete. Go ahead and save and activate your flow.

How to Test

  1. Before creating a new user, be sure you have an available license in Drive Connect to assign.
  2. Create a new Salesforce user in Salesforce setup. Be sure that the user is set to active.
  3. Once the user is created, check the Drive Connect licensing and permissioning page to see if the user was assigned.

 

 

Note: If you do not have enough licenses to automatically be assigned, Salesforce will not let you create users. On user creation, you will get an error page stating that you are unable to access the page.