Multi Object Distribution System – Distribution Flow

Updated 08/09/2022

If you have followed this tutorial so far you will have created the objects and the fields in the previous step. If you haven’t I recommend that you go back and complete that otherwise, you will be hacking things together on the fly. This will slow you down, and you may miss a field you need to set up.

Objective

By the end of this section, you will have built a flow that sits as a Subflow in other flows. We will also use the test distribution container and the distribution users we have created in the last step to debug this flow. The flow will handle the active users on an active distribution container and update the assignment in case of the user is inactive.

The complete layout of the distribution system Subflow we will complete

Set up Variables

We need two variables set up both as text variables DistroName and UserToAssign both need to be available for input and output. DistroName is the distributor name that is passed from the flow it is called in. UserToAssign will carry the Id of who the record that needs to be assigned. I would set this either to a current user or a queue owner.

Get Distribution Container

With the DistroName that has been passed, we will use this as the filter criteria on Distribution Container. The fields we need to save are the following:

  • Next_Assignment__c
  • Number_Of_Times_Ran__c
  • Active__c
  • Number_Of_Users__c

Keep note of these fields; they are essential for the rest of this functionality further on.

Directly after this, we will build a decision based on Active__c being True or False. If it is False it will skip the distribution, If it is true this will run through the distribution.

Second Decision

We are checking for another decision this will act as a count resetter if the count is higher than the number of users on the Distribution Container. The following Values we are checking.

Next_Assignment Is Greater Than Number_Of_Users__c

Below the decisions we have an assignment that resets the value to 1 if this is true, else it passes to the next element without incrementing, don’t worry we will increment this further down.

Decision with Resetting Count or passing

Get Distribution User

We are now moving into the meat of the flow where the assignment takes place. We will create a Get Records setting the object to Distribution User we need to field this by setting the Distribution Container Parent Field to use the Id from the Distribution Container at the beginning of the Flow. It will also the number needs to be equal to the Next Assignment field.

Checking Distribution User Is Active

Now we have the distribution user we need to check if they are currently marked as active on this distribution container.

Is Not Active

If they are not active we will create an assignment element that increments the count and links back to the Next Assignment Checker.

Is Active

If they are active we will assign the user from the container to UserToAssign which will pass the UserId to the owner. We are incrementing Next_Assignment__c and Number_Of_Times_Ran__c by one. This will complete this part of the flow.

Both paths for looping back round if a user is inactive and updating Distribution Container.

Now we have completed this we will move on to the next flow which will set up the Distribution Container and Assign.

Published 24/08/2022
Category: Distribution, Tutorials

Other Posts