Author: S. McLaughlin

Step 3: Create a Business Process to run your Apex rule

Using a Business Process is easy to setup, and allows you to create multiple methods of running my assignment rules should you choose to do so.

Navigate to Admin > Create > Workflows & Approvals > Process Builder, and click on the New button.

Your new process looks like this before you configure it.

Click on the “Add Object” link and select the “Lead” object from the Object picklist. Select the “when a record is created or edited” choice under “Start the Process”. This is telling your process to execute whenever a record is new or an existing record is modified.

Click the Save button.

Next click the diamond shaped true/false step to enter in the criteria that executes the update. This is where you will need your Queue ID that we found in Step 1. Set the name of your step function. I chose “In Queue and Revenue Stage = MQL” as a descriptive way of describing the criteria that this step is looking for.

Now you can set the two filters:

Choose the default values for “Conditions are met” and “All of the conditions are met (AND)”. Finally, click Save.

The next step will be the configuration of the “Immediate Actions” logic that calls the Apex code, which re-assigns the lead to a salesperson.

The last step is to press the Activate button, and then test the process. Remember, you can invoke you new “Re-run Assigment Rules on Lead” Apex Class in any number of scenarios by building new processes with process builder.

 

I'm trying to create a trigger that will automatically re-route a lead through the default routing rules when a custom field checkbox is checked. I have the following code based on a suggestion by product mgmt through the ideas forum:

However, when I try to test this out on a lead, I receive the following error:

Apex trigger reassignLeads caused an unexpected exception, contact your administrator: reassignLeads: execution of BeforeUpdate caused by: System.SObjectException: DML statment cannot operate on trigger.new or trigger.old: Trigger.reassignLeads: line 12, column 1

I've also used the following code:

This code doesn't cause an error when I try to update a lead but it also doesn't re-route the lead. I assume, because it's using before update instead of after update. If I change trigger to after update, I get the following error:

Apex trigger reassignLeads caused an unexpected exception, contact your administrator: reassignLeads: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.reassignLeads: line 6, column 1

Is there a way to do this using a trigger or do I have to use a future call to a class?

triggerleads

0 comments

Leave a Reply

Your email address will not be published. Required fields are marked *