Rejection API Process

With more complicated business requirements there may be a need for actions or updates to occur after an assignment is rejected.  Below are the steps to find and implement the Distribution Engine Rejection API in Process builder and Flows

Process builder

As an example, the business would like that if a Lead's State/Province field is changed it is returned to the queue and assigned to a new agent based on the new State/Province criteria.

Step 1 create a new process
  • From the Setup area go to Create > Workflow & Approval > Process Builder and click New
  • Enter a name and set the process to start when a record changes and save
Step 2 add your object 

We want this process to fire when the lead is updated.  We'll be basing this on Lead and checking whether Distribution Engine has assigned the lead in the past to ensure there is a Distribution Log associated for the rejection.

  • Click add object in the flow diagram.
  • Select Lead and when a record is created or edited and save
Step 3 add the criteria for starting the process
  • Click the Add Criteria diamond.
  • Enter Criteria name: State Updated
  • Enter the conditions

1. [Lead].State Is changed True 

2. [Lead].n2de__Distribution_count__c Greater than or Equal to 1

  • Save
  • Click the Immediate actions box next to the right of the 'State Updated' diamond
  • Action type: Apex
  • Action name: Reject Assignment
  • Apex Class: DE Reject Record
  • Set Apex Variables
  1. Record id - Type: Field Reference, Value: [Lead].Id
  2. Reason to reject - Type: String, Value: StateUpdated
  • Save
Step 5

Your finished process should look like the example below.

Activate your process.

After Distribution Engine has assigned a Lead, if the State/Province field is updated the record should return to the queue/user as indicated on the distributor detail.

Lightning Flow

The Rejection API can be leveraged in Lightning Flow with an Action element.

  • Select 'Action' from the Elements tab on the left.
  • In the 'New Action' pop-up choose 'Distribution Engine' on the left.
  • Click in the 'Action' dropdown box and 'DE Reject Record' will populate as an option.
  • Choose a Label and API Name will auto-populate
  • Choose a description
  • The DE Reject Record action requires two input values:
    • Reason to reject: Input from the user most commonly from a Screen element further up in the Flow
    • Record Id: a variable labelled 'recordId' can be automatically assigned the Id of the current record, if the flow is imbedded as a Lightning component on the Lightning page.

A simple Flow may look similar to this:

How did we do?

Opportunity Assignment - Updating Related Accounts & Contacts

Assign License and Permission Set on Team Member Addition

Contact