function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AustralianBobAustralianBob 

Lead Notifications via a Trigger

Hi,

 

I think this is easy, but it will need Apex...

 

Short version,

Need help crafting Apex code and tips to implement to send out out an email when a Lead is assigned to a Rep. Have a template that would like to use and we have Round Robining on Leads in place.

 

Is there some relatively short code to use!? Appreciate any guidance :)

 

Long version

Collecting around 400 leads a month. It was a requirement of our deployment that Leads Round Robin instead of the default queue behaviour. This was accomplished using an Assignment Group Package

 

That's working fine, but it seems to stop the immediate automated notifications from working.

I believe this is because this system has Leads "owned" briefly by the queue before changing the owner to a relevant individual.

 

So a Lead is created, the queue notifications are run (as well as any out of workflows) before owner is changed to a Sales Rep, then the assignment is changed and notifications aren't triggered again.

 

To confirm, an immediate notification DOES work if leads are "Assigned to Group" by a user, but when they are first Created the immediate notifications don't cooperate.

 

The only way I could get this to work at all was to have the notification on a Time Delayed workflow - the smallest increment is one hour and really this is too slow on a New Lead notification.

 

If there's an alternative fix happy to try, but otherwise would appreciate some help with the code...

Have found some code

tested in Sandbox

I believe I should also make sure to use "TargetObjectId" to avoid limits?

 

THANKS!!!

 

RoyGiladRoyGilad
Hi Ozibob,
You can Round Robining the Leads using out-of-the-box assignment rules:
1) Add a numerator to the lead object
2) Create a formula field that use the MOD() function using the number of reps you have.
3) In your assignment rule use the result of the formula (a number) as part of the criteria.

Do you think this could work for you?


AustralianBobAustralianBob

Thanks Roy,

 

We're using the Round-Robining function laid out by Assignment Groups on the AppeExchange, applied to Leads

AG on ApExchange

 

I believe this was used as we have quite a large sales team distributed over 6 different states who receive leads which are grouped by 3 different "tiers" - the AG app provides a decent mechanism to maintain the groups and who is or isn't active in different teams.

 

I believe when Leads are moved to your name you're meant to get an email automatically, but this app seems to nix that from cooperating somehow...?

 

Backing this out for another system would be tricky!