Getting Started with Process Builder – Part 79 (Auto Remove Managed Package License from a Deactivated User!)

Getting Started with Process Builder – Part 79 (Auto Remove Managed Package License from a Deactivated User!)

Last Updated on December 5, 2020 by Rakesh Gupta

Process Builder in Salesforce is a fantastic way to automate various business processes. It allows you to create a process based on certain criteria that you set. Process Builder can do many things – Create a record, Update records, Post to Chatter, Send an email, etc. A few years back – in September 2015 – I wrote an article Auto Assign package license to New user to show how one can automatically assign managed package license to new users. 

The overwhelming positive feedback was followed by requests – to write another blog showing how to automatically remove managed package license from deactivated user(s)! Below is one of the sample emails – from a gentleman whom I know not, but would like thank for making the request. For, requests and ideas from my blog readers have immensely contributed towards my mastery of the Salesforce Platform!

I am looking for a way to automatically delete an installed package members whenI inactivate their User account. Currently, I have to delete the User; then delete them from the installed package. Is there a way via PB and/or Flow? I'd like an automated deletion process that captures all associations.

Thank you,
Erin Ryan

In this blog post, I will show you how to leverage process builder to automatically remove managed package license from the deactivated users. Let us start with a business use case.

Business Use Case

Martin Jones is working as a System Administrator at Gurukul on Cloud (GoC)At GoC they are using  Conga Composer to streamline and scale their document generation process and Resco to use true offline mobile capability for their Sales and Field Service reps. Martin received a requirement from the management to auto remove managed package licenses as soon as a user’s account is deactivated.

Solution for the above business requirement

Before we proceed, let us first ponder – why do we need to automate this process in the first place? 

On AppExchange, App providers use managed package, partly, to hide the code and implementation logic from customers. Another benefit of a managed package is that app providers can easily push updates to their customers’ org in one stroke.  

When a user’s account is deactivated is Salesforce, his/her Salesforce license is released and available for reassignment. Such is not the case vis-a-vis the deactivated user’s managed package license. For despite being deactivated, a user’s managed package license is not automatically removed from his/her account; the System Administrator has to manually remove the managed package license from the deactivated user’s account.

There are a few possible solutions for the above business scenario, but we’ll use  Flow and Process Builder to solve the above business requirementBefore trying to understand the technical aspect of the solution, let us spend some time to understand the general flow of our solution at a very high level. Please spend few minutes to go through the following flow diagram and understand it.

Before we proceed further, let us understand the characteristics of UserPackageLicenseobjects object – It represents a license of an installed managed package, assigned to a specific user.

Step 1: Create a Flow to remove managed package licenses

  1. Navigate to Setup (Gear Icon) | Setup | PLATFORM TOOLS | Process Automation | Flows. Click on the New Flow button; it will open the Flow canvas for you. Create variables in the Flow, as shown in the following table:
    Name Variable type Input/Output type
    VarTPackageAssignmentID Text Input and Output
    VarTUserID Text Input and Output

    We will pass the value to VarTUserID through Process Builder.

  2. The next task is to check whether a managed package license is assigned to the user. For this, we will use the Get Records element. To do this, drag and drop the Get Records element onto the canvas; it will open a new window for you. Map the Record Lookup element according to the following screenshot:Part 79.1
  3. The next task is to check whether VarTPackageAssignmentID – i.e. whether any managed package license is assigned to the user or not. To check this, we will use the Decision element. To do that, drag and drop the Decision element onto the canvas; it will open a new window for you. Enter the details as follows:
    1. Name: Enter the name Check manage package license assignment
    2. Unique Name: This will be auto-populated based on the name.
    3. Description: Enter a meaningful description.
    4. Outcome: Enter the name Assigned as EDITABLE OUTCOME. Select the variable {!VarTPackageAssignmentID} as Resource, then is null as Operator, and {!$GlobalConstant.False} as the value
      Part 79.2
  4. The final step is to add a Delete Records element to remove the managed package license assigned to the user’s account. To do this drag and drop a Delete Records element onto the canvas; it will open a new window for you. Map the Record Delete element according to the following screenshot:Part 79.3
  5. Use the connector to connect the elements used in the Flow. Finally, your Flow will look like the following screenshot:Part 79.4
  6. Save the Flow (Type: – Autolaunched Flow) and name it Auto remove package licensesThen, close the canvas. Don’t forget to Activate the Flow.

Step 2: Create  a Process to launch a Flow 

Our next task is to create a Process Builder on the User object to start a Flow. To create a Process Builder on the User  object follow the steps below:

  1. Click on Setup (Gear Icon) | Setup | PLATFORM TOOLS | Process Automation | Process Builder
  2. To create a new process from scratch, click on the New Button available on Process Management page. A popup will appear where you have to enter the Name (Use Auto remove package license from deactivated user as a name)API Name and Description as shown in the following screenshot:
  3. Click on Object node to add object and then select the User object. For the entry criteria, select when a record is created or edited, as shown in the following screenshot.
  4. Once you are done, click on the Save button.
  5. The next task is to add Process Criteria. To do this, click on Add CriteriaThen, enter NameType of action and set filter conditions as shown in the following screenshot:
  6. Once you are done, click on the Save button.
  7. The next step is to add an Immediate action to Process. Click on Add Action (Under Immediate actions). Then select the type of action to create (In our case Flows). Use Field Picker to choose the field [User].Id, as shown in the following screenshot:
  8. Once done, click on the Save button.You will be redirected to Process canvas page. 
  9. Finally, the Process will look like the following screenshot:

Don’t forget to activate the Process by clicking on the Activate button.

It’s time to test the Flow and Process!

First of all, navigate to the Installed Package and check the licenses used for various apps, as shown below: 

Now, deactivate a user’s account to whom you have assigned managed package Conga Composer and DocuSign For Salesforce license. For proof of concept, please refer the following video: 

Technical Editor and Proofreader: - Munira Majmundar

 

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

 

 

8 thoughts on “Getting Started with Process Builder – Part 79 (Auto Remove Managed Package License from a Deactivated User!)

  1. Hi Rakesh

    As this was written in 2018 and flow is evolved.

    Is it possible not to use PB & have everything done in 1 flow ? I think yes but need your input.

  2. Hi,
    I am looking for a way to automatically delete an active campaign when I inactivate campaign owner User account. Is there a way via PB and/or Flow? I’d like an automated deletion process.

    Thank you,

  3. In that case where should I set this condition that if user is inactive and last login is more than 30 days , then remove installed package. As we do not want to remove installed package as soon as user is inactive but wait till 30 days. Also when we are removing , process should again check if user is still inactive.

    Is a way to send email for number of user records impacted?

    1. You have to use time-based action

      1. Fire your process once a user gets inactive
      2. Then use time-based action after 30 days
      3. Use Flow to remove the package license from the user.
      4. Use Static action. – Email in the flow to send notification of system administrator or group of users

  4. can we remove licence after 30 days of user deactivation. As well what is better to use batch job or process builder in this scenario?

    1. Yes you can remove package license after 30days. As you are not going to deactivate lots of users every weeks, I think using process builder in this case make sense

Leave a Reply

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