+ Start a Discussion
Swaraj Behera 7Swaraj Behera 7 

LeadId in opportunity

In my current requirement i want to get all the attachments from lead and need to attach it in the opporunity after conversion.I have created a trigger in opportuniy but it did not work.Can anyone help me on this.

Thanks in Advance.
NagendraNagendra (Salesforce Developers) 
Hi Swaraj Behera 7,

Using a SOQL query I was able to retrieve all of the notes and attachments separately, then iterating through each of the notes and attachments individually - I create new instances of a note or attachment and assign the values from those retrieved notes and attachments. After the creation of each note or attachment I add those to an insertList for each respective one and then add this insert insertListAttachment and insert insertListNotes.
This allowed me to convert the attachments and notes from a lead object.

Note:  Be sure to check the standard fields for a note and attachment object.


If you are talking about using a trigger to do all of this?
Well, the way that I did it was by creating a custom button that executes a javascript function when clicked. This javascript executes an apex class. Inside of the javascript, I retrieve the current lead id and then pass this information to the class. Using this leadID I create SOQL queries that retrieve all the information related to that particular leadID. I then proceed to use the information from the lead to create a new project and pass the lead info to that newly created project. Then I simply insert this project. My method might require a little bit of programming experience. Let me know if you would like some help with the issue.

Please mark my solution as the best answer if it helps you.

Best Regards
Nagendra.P