Getting Started with Process Builder – Part 43 (Auto Assign Package License to New Users)

Getting Started with Process Builder – Part 43 (Auto Assign Package License to New Users)

Last Updated on December 1, 2020 by Rakesh Gupta

Big Idea or Enduring Question:

  • How can you automatically assign a managed package license to new users? 


This blog post will help us to understand the following

  • Launch a Flow from Process Builder
  • Use Flow and Process Builder to automatically add a package license to the new users

Business Use case

Pamela Kline is working as a System administrator at Universal Containers (UC). They are using Conga Composer to streamline and scale their document generation process. She has received a requirement from the management to auto-assign Conga Composer license to new users. Which helps them to minimize the post user creation manual activities. 

Automation Champion Approach (I-do):

A few months back, I had written an article Getting Started with Process Builder – Part 24 (Automatically Add User to a Chatter Group) to discuss a way through which you can automatically add new users to Chatter Group. To achieve it, we used Process Builder and Global Action.

I got really good feedback from all of you and a few of them requested to explain a way through which they can automate the package license assignment process. In this blog post, I will walk through setting up a process builder to automate the package license assignment process. 

There are a few possible solutions for the above business scenario. We will use Flow and Process Builder to solve the requirement. 

Let’s take a pause here, familiar yourself with the UserPackageLicenseobjects and PackageLicense objects in Salesforce. 

Object Name Details
UserPackageLicense It represents a license of an installed managed package, assigned to a specific user.
PackageLicense It represents a license of an installed managed package.

Before discussing the solution, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.

Let’s begin building this automation process.

Guided Practice (We-do):

There are 2 steps to solve Pamela’s business requirement using Flow and Process Builder. We must: 

  1. Lightning Flow Steps:
    1. Define flow properties for auto-launched flow
    2. Add a record variable to store user record data 
    3. Add a get records element to find conga composer package license id
    4. Add a create records element to assigned package license to the new user
  2. Process Builder Steps:
    1. Define process properties
    2. Define evaluation criteria
    3. Define process criteria
    4. Add action – flows 

Step 1.1: Lightning Flow – Define Flow Properties 

  1. Click Setup.
  2. In the Quick Find box, type Flows.
  3. Select Flows then click on the New Flow.
  4. Select the Autolaunched Flow (No Trigger) option and click on Next and configure the flow as follows: 
    1. How do you want to start building: Freeform
  5. Click Done.

Step 1.2: Lightning Flow – Add a Record Variable to Store User Record

  1. Under Toolbox, select Manager, then click New Resource to store user record.
  2. Input the following information: 
    1. Resource Type: Variable
    2. API Name: varRUser
    3. Data Type: Record
    4. Object User
    5. Check Available for Input
    6. Check Available for Output
  3. Click Done.

Step 1.3: Lightning Flow – Adding a Get Record Element to Find Conga Composer Package License id

The next step is to use the Get Records element to get the Conga Composer installed package Id.

  1. Under Toolbox, select Element
  2. Drag-and-drop Get Records element onto the Flow designer. 
  3. Enter a name in the Label field; the API Name will auto-populate.
  4. Select the Topic object from the dropdown list.
  5. Select All Conditions Are Met (AND)
  6. Set Filter Conditions
    1. Row 1:
      1. Field: NamespacePrefix
      2. Operator: Equals
      3. Value: APXTConga4
  7. How Many Records to Store:
    1. select Only the first record
  8. How to Store Record Data:
    1. Choose the option to Automatically store all fields
  9. Click Done.

To find the Namespace Prefix of installed packages, navigate to Setup | Apps | Packaging | Installed Packages, as shown in the following screenshot:

Namespace Prefix

Step 1.4: Lightning Flow – Create Records – Assign Package License to New Users

The final step is to assign the conga package license to the new users. Drag and drop Record Create onto the flow designer and map the fields according to the below details. 

  1. Under Toolbox, select Elements. Drag and drop Create Records onto the canvas. 
  2. Input the following information:
    1. Enter Label the API Name will auto-populate.
    2. How Many Records to Create: One
    3. How to Set the Record Fields: Use separate resources, and literal values
    4. Object: User Package License
    5. Set Field Values for the User Package License
    6. Row 1:
      1. Field: PackageLicenseId
      2. Value: {!Conga_Composer_Package_License_Id.Id}
    7. Click Add Field
    8. Row 2:
      1. Field: UserId
      2. Value: {!varRUser.Id}
  3. Click Done.

In the end, Pamela’s Flow will look like the following screenshot:

Once everything looks good, perform the steps below: 

  1. Click Save.
  2. Enter Flow Label the API Name will auto-populate.
  3. Click Show Advanced.
  4. API Version for Running the Flow: 50
  5. Interview Label: Assign Conga Package License {!$Flow.CurrentDateTime}
  6. Click Save

Almost there! Once everything looks good, click the Activate button.  

Our next task is to create a Process Builder on the User object to launch a Flow when a user is created. To create a Process Builder on the User object follow the below instructions.

Step 2.1: Define Process Properties

  1. Click Setup.
  2. In the Quick Find box, type Process Builder.
  3. Select Process Builder, then click New.
  4. Name the Process and click the Tab button. The API Name will populate. 
  5. As a best practice, always input a description
  6. The process starts when A record changes.
  7. Click Save.

Step 2.2: Define Evaluation Criteria

  1. Click on the Add Object node to begin selecting the evaluation criteria.
  2. Select the User object from the dropdown list.
  3. Start the process only when a record is created.
  4. Click Save.

Step 2.3: Define Process Criteria

  1. Click the Add Criteria node to begin defining the process criteria.
  2. Name the criteria.
  3. The criteria should execute actions when the conditions are met.
  4. Set Conditions
    1. Row 1
      1. Field: User | IsActive
      2. Operator:  Equals
      3. Type: Boolean
      4. Value: True
  5. Select All of the conditions are met (AND)
  6. Click Save.

Step 2.4: Add Action – Flows

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Flows
  3. Name the action.
  4. Select the flow we just createdAssign Conga Package License.
  5. Set Flow Variables: 
    1. Row 1:
      1. Flow Variable: varRUser
      2. Type: Field Reference
      3. Value: Select the User record that started your process
  6. Click Save.

In the end, Pamela’s Process will look like the following screenshot:

Almost there! Once everything looks good, click the Activate button. 

Proof of Concept

Now onwards, when a user account is created, Process Builder will automatically trigger and launch the Flow. It will then add a package license (Conga Composer) to the newly created user. Let’s test it out.

  1. Now create a new user via the UI
  2. Once the user is created, our automation will automatically assign the package license to the newly created user. To Validate You can either query on the User Package License object or navigate to Setup | Apps | Packaging | Installed Packages | Conga Composer | Manage Licenses. 

Formative Assessment:

I want to hear from you!  

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? 

Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

13 thoughts on “Getting Started with Process Builder – Part 43 (Auto Assign Package License to New Users)

  1. Rakesh Hi,
    Thank you very much for the useful post.
    Can you elaborate the reason you’ve added a Time Based Action?

    Furthermore, can you explain how to auto remove a package license from a deactivated user? (once he is deactivated, the license will be removed from his user).


  2. Thank you for quick response.
    So, Use Record Lookup for Package, connect to Record look up Permission set, Connect to Record create user? I am trying to assign to users who are or will be assign to 3 different permission sets. with monthly 300 limits.

    1. What i am trying to explain, first use Record lookup element to find if he permission sets is already assign or not. Then go ahead and assign Package License

  3. Hi Rakesh, You have always been a help. I have qq;
    Is it possible to assign package license only to users that are assign to certain permission sets?

    Thank you in Advance!!

    1. Glad to know 🙂

      To assign package license only to users that are assigned to a certain permission set, follow the instructions below

      1. Use Record Lookup element (on PermissionSetAssignment object) for that particular user. Store the ID in a variable – PSAID
      2. Then use Decison element to check PSAID varibale. If it is blank then stop here else connect it to the rest of the Flow

  4. Hi Rakesh,

    This is a great blog you have here. I always look up to this blog for automation related issues. Thank you very much for taking time to put together such easy and clear steps for automating stuff.

    Quick question – i do not see the object ‘PackageLicense’ in the flow. Is that removed? or renamed?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.