skip to Main Content

Use Microsoft Flow to: Copy a Qualified Lead’s Notes to the new Opportunity

The qualification or disqualification of a Lead in Dynamics 365 is a human triggered event that kicks off a predefined process. That process will convert the Lead to a new Contact and Account record and also create an Opportunity that is associated with the Contact and Account. There will also be a link back to the originating lead in the Opportunity record.

But what happens to important pieces of information that were recorded in the CRM user’s conversations with the Lead? Absolutely nothing! They stay with the Lead record and remain several clicks away from the Opportunity record and are basically out of sight and out of mind.

I started thinking about how to solve this challenge with Microsoft Flow after seeing a post on the CRMUG Community support forum.

This is what I have come up with as one approach to copy the Notes and attachments to the Opportunity record automatically. You could also approach it differently by changing the regarding on the Notes from the Lead record to the new Opportunity record. Modify it to fit the way your company wants it to work.

Here is a big picture of what the Flow looks like. (if it looks a little scrunched on your screen, click on it to get a bigger view):

Copy a Lead's Notes to an Opportunity

Let’s break down each step in the Flow:

Step 1 – Listen for the creation of a new Opportunity and then get all the field data from the Opportunity record. We will need some of that info in later steps.

Get New Opportunity Record

Step 2 – Check to see if the Opportunity was created as a result of the Automated Lead Qualification workflow. We do this by checking to see if the attribute field on the Opportunity record has any data in the Originating Lead Lookup field (look for this in the Marketing section of the Opportunity form)

Did the Opportunity originate from a Lead

Step 3 – If it resolves to False, it means the lookup field is not empty, ie it came from a Lead, so then go down the Yes path. If it didn’t come from a Lead conversion we don’t need to do anything so we don’t need any steps for the No result.

Did the Opportunity come from a Lead

Step 4 – Now lets get all the Notes for the Lead record and then loop through them using the Apply to Each function to make a Copy of the Lead Note to a New Note along with the attachment, if any. And set the regarding to the new Opportunity.

Duplicate the Notes

There you go. The takeaway is the List and Apply to Each Actions in Microsoft Flow is the greatest thing to happen for us in the Dynamics 365 world.

This Post Has 17 Comments
  1. Hi Jerry,

    This is a cool idea to use Flow. I have a question though. I recreated your flow identically and it works as expected. However I wanted to use this same concept to carry over a custom entity that we have linked to the lead and move it to the contact. But when I set it up similar to this flow it loops through ALL of the records for that custom entity instead of just the ones that are related to the Lead. The Flow works as I wanted as it’s setting the link to the contact but it’s also setting all of the records in the system to this one contact. Any thoughts?

    1. Susan,

      How would you get the BPF to iterate through all the Notes?

      Unless you are suggesting that it be triggered by the BPF and run asynchronously vs being an instant Flow?


      1. Thanks for the reply, reason I asked is because I did create a flow under My Flows but this did not work I am not sure if the flow ran but there is something wrong in the setup of if it was never activated. One main difference I used the Dynamics 365 connector and not the Common Data Service.

          1. I am getting close! I created it as a CDS trigger but having problems with the expression for the condition, I get the following error: The template validation failed: The actions(s) ‘Get_Opportunity_Record’ referenced by ‘inputs’ in action ‘Did_it_originate_from_a_Lead’ are not defined in the template.

  2. Thanks I did convert to a CDS trigger, had trouble with the condition expression so I used an alternative. Only problem it copied over all notes and not just the ones related to original lead.

    1. Susan,

      See step 4, you must not be filtering correctly – You need to have the correct filter expression in the find leads from the same company action. It should look like this companyname eq ‘@{triggerBody()?[‘companyname’]}’ and statecode eq 0


      1. Thanks Jerry for your support and this great blog. Yes it was a filter that was missing the one I added was in the step List Notes for the Lead, advanced options:
        _objectid_value eq ‘@{body(‘Get_Lead’)?[‘leadid’]}’
        Also because there can be several notes to copy, I wanted them in the same order so I added an order by: createdon asc
        The expression had me puzzled for a while, this is my first attempt at a flow and the Advanced option is not available, but I resolved that by first selecting the parameter for originatinglead, is not equal to, and then using the Null function.
        This was a fun learning experience and I look forward to creating more flows.

  3. Hi

    I’m having difficulty applying this flow to my organization.

    I wasn’t able ‘save’ the template to My Flows, so I built a new flow step by step to look exactly like this flow. I saved the flow, and when I log in to, I can see the flow under ‘my flows’ on that page.

    However within Dynamics 365 (CRM), when I go to Settings > Microsoft Flows, the page says ‘You don’t have any flows.”

      1. Thanks Jerry

        I was able to get a bit of help from MS support – they advised that the Flows don’t appear in 365 unless they begin with the ‘When a record is selected trigger.’

        They referred me to the ‘Tip’ on the bottom of this page:

        The Flows menu only list flows that begin with the When a record is selected Common Data Service trigger and contain at least one trigger or action that references that entity.

        They assured me that even though I can’t see the Flow in D365, the Flow is functioning. We tested a few times and the Flow does seem to work even though it isn’t visible within D365. Does this sound normal? Since this flow is triggered automatically it wouldn’t necessarily help to have it available from the drop down menu, would it?

  4. I noticed one issue with this flow – when the notes are copied from the Lead to the Opportunity, the ‘owner’ of the note on the opportunity is changed from the Salesperson to myself. I assume this is because the Flow is connecting to the CDS using my own credentials.

    Is there a way to workaround this?

    1. David,

      There will be a capability coming to Flow as part of 2019 Wave 2 (October) that will allow you to run an action in an impersonation mode. In the mean time, you would have to update the action to transfer ownership.


Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top