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
Elliot2642Elliot2642 

Change Lead owner by Last Logged Activity

Hi all,

 

Let me preface this by saying that I have very little coding experience.

 

That being said, our company has a particular business request and I'm not sure where to start. We would like to put a mechanism in place so that when a Lead Record has had no Activity Records in the past 3 months AND there are no Open Activities, that the ownership of the Lead will change to a queue. If anyone can please point me in the right direction as to where to start / learn how to go about such a project, it would be very much appreciated.

 

Thanks,

Elliot

Best Answer chosen by Admin (Salesforce Developers) 
AroraAnupAroraAnup

Hi Elliot,

 

I wish I could point you to a document online, but this is not a standard solution. This is a custom solution that we built specifically for a project need for Service Cloud! But I definitly share some notes from the design document that I authored for this requirement (I will tailor the notes to make it more specific to your requirement:

 

1. Objects in scope:

a. Leads

b. Activities

 

2. Add 2 new fields (one to be updated on changes to the Lead record and other to be updated on changes to Activities records) You can choose to keep them hidden from the layout.

 

3. Lead Trigger - You would need to write a trigger on Leads that continues to monitor the Lead for changes within 90 days from the Last Modified Date. If no changes happen on the Lead, this trigger will update the Lead custom field. We could have also done this using a workflow with time-based action, but this requires continues monitoring of the Lead record, which means we would have to use the Workflow criteria of "Every time the record is created and updated" and unfortunately Time-based actions are not supported on Workflows with such criteria. Hence trigger is needed.

 

4. Activity Trigger - You would need to write a trigger on Activities that continues to monitor the Open and Closed Activities for changes/new records within 90 days from the Last Modified Date of the Lead. If no changes are there, this trigger will update the second  custom field on Leads

 

5. Workflow - You can then use these 2 fields to trigger a Workflow field update to change the Lead Owner to a Queue. You can even use the trigger to do this but I would recommend workflows.

 

I hope this helps you make progress on the requirement. Let me know if you still face a roadblock and I would be glad to extend more help!

Good luck!

All Answers

AroraAnupAroraAnup

We have had a similar requirement in the past, not on Leads but on Cases, where is there is no activity on a Case for a considerable period of time, the Case should be sent back to the original Queue. 

There are several objects that have to be considered in this requirement:

 

1. You need to monitor the Lead object itself to check if its been modified in the last 3 months i.e. you need to calculate the days from Created Date/Last Modified Date to the Current date to check for any changes.

 

2. You also need to monitor the Activities Object to look for any Open or Closed Activities within the 3 months period, again considering Point # 1

 

3. You also need to check for the Lead History to track changes in Lead Ownership and send it back to Original Queue or a pre-defined queue as per the requirement

 

In the nutshell, this requirement will require a combination of Trigger and Time based workflows. You will require a Trigger to check the pre-requisites across the various tables. This trigger can then update a field, which you can then use as a criteria in your time-based workflow to change the Lead Owner to a Queue.

 

Hope this helps! Do click KUDOS if you feel that this is a helpful post :)

Elliot2642Elliot2642

Hi CloudKnight,

 

Very helpful! Would you be able to direct me to some documentation that could help me get started?

 

Thanks,

Elliot

AroraAnupAroraAnup

Hi Elliot,

 

I wish I could point you to a document online, but this is not a standard solution. This is a custom solution that we built specifically for a project need for Service Cloud! But I definitly share some notes from the design document that I authored for this requirement (I will tailor the notes to make it more specific to your requirement:

 

1. Objects in scope:

a. Leads

b. Activities

 

2. Add 2 new fields (one to be updated on changes to the Lead record and other to be updated on changes to Activities records) You can choose to keep them hidden from the layout.

 

3. Lead Trigger - You would need to write a trigger on Leads that continues to monitor the Lead for changes within 90 days from the Last Modified Date. If no changes happen on the Lead, this trigger will update the Lead custom field. We could have also done this using a workflow with time-based action, but this requires continues monitoring of the Lead record, which means we would have to use the Workflow criteria of "Every time the record is created and updated" and unfortunately Time-based actions are not supported on Workflows with such criteria. Hence trigger is needed.

 

4. Activity Trigger - You would need to write a trigger on Activities that continues to monitor the Open and Closed Activities for changes/new records within 90 days from the Last Modified Date of the Lead. If no changes are there, this trigger will update the second  custom field on Leads

 

5. Workflow - You can then use these 2 fields to trigger a Workflow field update to change the Lead Owner to a Queue. You can even use the trigger to do this but I would recommend workflows.

 

I hope this helps you make progress on the requirement. Let me know if you still face a roadblock and I would be glad to extend more help!

Good luck!

This was selected as the best answer