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
Vin.Vin. 

Generating new leads with closed opportunities.

Hi, 

I have closed opportunities (closed won and closed lost) for one of my record type (which correspond to one product) that I would like to use in order to automatically generate new leads after a certain time.

For instance, I would like my closed won opportunities for outside sales to automatically generate new leads after a year.

Does someone know how to make it ? Is it possible with a trigger ? Is it possible without a trigger (more user friendly solution, no code required)?
Best Answer chosen by Vin.
Shruti SShruti S
You can easily do this with the help of Processes. Here are screenshots for getting it done - 

User-added image

User-added image

User-added image

User-added image

User-added image

You can right click the images and select "Open imag in new tab" to view a larger version of it.

Feel free to ask if you have any more doubts.

All Answers

Shruti SShruti S
You can easily do this with the help of Processes. Here are screenshots for getting it done - 

User-added image

User-added image

User-added image

User-added image

User-added image

You can right click the images and select "Open imag in new tab" to view a larger version of it.

Feel free to ask if you have any more doubts.
This was selected as the best answer
AvaneeshAvaneesh
Hi 

Yes, you can write a trigger but you have to use tricky solution Or better than that you can write a batch writing a batch will be easy but if you want to go with trigger then ......... 

1-Create a formula field in opportunity object that has to calculate [Date Established] + 365days. 
2-
 Write trigger in Opportunity and check the value of formula field and if this was satisfying your criteria then create your lead 

if this was helpful let me know 

Thank you
Avaneesh Singh
Vin.Vin.
Thank you so much guys !

I believe Shruti's solution is the most convenient. I started to set it, however I would like to ask for some clarification :

Could you please tell me how to send the new Lead to a specific record type : it should become a Lead for our "outside sales" (the same record type as the one of the closed Opportunity)?

Do you also know how to assign this new Lead created to the same Owner as the Opportunity Owner ?

Thanks a lot !
Shruti SShruti S
Here is a screenshot on how you should be getting this done -

User-added image

The box where you see 'xxxxxxxxxxxxxxxxxxx' should be replaced by the 18 digit Id of the Record Type. 
To find the Record Type Id of "outside sales", execeute the following query in the Query Editor of your Developer Console - 
SELECT Name, SobjectType, Id FROM RecordType WHERE Name = 'outside sales' AND SobjectType = 'Lead'
Feel free to get back if you have any more doubts.
Vin.Vin.
Thanks a lot Shruti! Your explanation is really clear !


Could you also clarify which Opportunity is the one sending all information (email, premium, claim date ...) to the Lead ? For example if I close an Opportunity in 2017, then in 2018 a new Lead is generated with the information pulled from the 2017 Opportunity. Finally, in 2019 a new Lead in generated thanks to the process builder. Will this Lead be filled up with the information from the 2017 Opportunity or from the 2018 Opportunity ?



Last thing, I am mapping all the fields that should appear on the new leads. However, I don't manage to link the field "Current Insurer" with the "selected insurer" from the previous opportunity:
User-added image
User-added image

The field "Current Insurer" is a text(255) while selected insurer is a lookup field, is this the reason ? If yes, is there a workaround ?

Thanks a lot !