2

Background

I am using Web-to-Lead, Lead assignment rules, Process Builder and Docomotion.

All leads created via web-to-lead are assigned to Bob.

Then the lead assignment rules share the leads in a round robin style to:

  1. John
  2. Jane
  3. Sam

Then Process Builder (using a Docomotion Apex InvocableMethod) sends an email to the email address on the Lead.

Unfortunately, the email is sent from the email address of Bob.

Like this:

From: bob@example.com < bob@example.com > On Behalf Of Bob Boberts

Whereas, I need it to come from:

From: john.doh@companyname.com


I've updated the process criteria such that it will only fire when the Owner.Email address is not Bob Boberts, and it fires, yet the email is still from Bob Boberts email address.


Question

How can I get the lead ownership to change before the email is sent?

  • 1
    Can you change the flow of execution to Assignment rule -> Workflow rule field update (select Re-evaluate Workflow Rules after Field Change) -> Process builder – Santanu Boral Sep 23 '18 at 5:12
  • @SantanuBoral I am not 100% clear what you mean, please could you elaborate? – Robs Sep 23 '18 at 10:24
3
+50

I've solved related issues with a strategy like this:

  • In before insert trigger; set a custom field Has_Been_Round_Robin_Assigned__c to FALSE
  • In your lead assignment rules, the first rule checks the aforementioned custom field for false and assigns the Lead to a Queue called 'Pending Assignment' . Be sure to uncheck the email box on the right side of this assignment rule.

  • Because of lead assignment, the trigger will re-execute. If the ownerId is the Pending queue, you can then use Apex to a) set the checkbox to TRUE and b) update the Lead using the AssignmentRuleHeader. Doing this in a future method avoids recursion.

  • the assignment rules run again but the first assignment rule is skipped, the remaining rules execute to the intended round robin owners.
  • The PB can inspect the value of the checkbox (or whether owner is the Pending Queue) to know that the Lead has been round robin assigned.
  • your approach is nice – Santanu Boral Sep 24 '18 at 11:14
  • I have a boolean field Owner_Assigned__c which is False by default. I the have a process which sets it to True. Then my other process only fires when the Owner_Assigned__c is True yet the email is still coming from the web-to-lead default user. – Robs Sep 24 '18 at 18:00
0

Have you tried using a time deferred action on the process builder? May be you can schedule the Email to go out 5 mins later?

Another method to try out would be to, set a boolean field on the record which says, ready to send email? , set this email to true only when the owner of the lead record is not the default user. Use the update on the boolean field to trigger the processbuilder email.

  • Process Builder Scheduled Actions takes 1 hour as the minimum time. This is too long. – Robs Sep 24 '18 at 17:58
  • I have a boolean field Owner_Assigned__c which is False by default. I the have a process which sets it to True. Then my other process only fires when the Owner_Assigned__c is True yet the email is still coming from the web-to-lead default user. – Robs Sep 24 '18 at 18:00
  • Robs, Does your first process has the tick for triggering the process/rules again? I will untick that for the process that set the flag to true. – Gaurav Thakur Sep 25 '18 at 3:46
0

This behaviour is happening because the Docomotion Apex InvocableMethod sends from the Transaction user, which is the web-to-lead User.

Solutions would be:

  1. Use a different user as the default web-to-lead user

  2. Write your own Apex InvocableMethod to generate the PDF and email it

  3. Wait until Docomotion release an update allowing you to set an Org Wide Email Address as the sender

-1

I think it is happening because of the execution flow. Process builder gets invoked and it still uses the owner since the changed owner has not been committed in the database.

Instead of Process Builder, can you not just use the Auto-Response rule where you can specify the sender's email too.

Also, you can call the apex invocable method only when the owner changes in your process builder.

  • Unfortunately, I cannot use Auto-Response rules as I am using Docomotion to generate a PDF and attached and send. – Robs Sep 21 '18 at 7:43
  • In the email alert, what is the From Email Address set to? Is the current user? – Naval Sharma Sep 21 '18 at 7:47
  • You can use a work-around. Trigger your email alert when owner is changed to something else? – Naval Sharma Sep 21 '18 at 7:48
  • 1
    I am not using an email alert. I am using an Apex InvocatableMethod provided by Docomotion – Robs Sep 21 '18 at 8:20
  • You can call that invocable method on owner change event in the process builder, – Naval Sharma Sep 24 '18 at 10:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.