Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Help building a Flow/Power Automate to copy a record

  • 1.  Help building a Flow/Power Automate to copy a record

    SILVER CONTRIBUTOR
    Posted May 10, 2021 04:01 PM
    I'm having some trouble with building my flow.  Here's the scenario:

    I have two custom entities:  Warranties and Projects.  I have created an instant Flow to create a new project record whenever the flow is run, and it will copy over certain fields.  I can get the flow to work up until the point where I need to copy over 5 different lookup fields and 4 related entities in 4 different sub-grids.  If the fields are open text or date fields, the flow works just fine.  I cannot however figure out how to copy over the related records.

    My flow is setup as follows:

    1.  When a record is selected --> Warranties
    2.  Get row -->  Warranties
    3.  Add a new row --> Projects --> (fill in the blanks)

    What would be the next step?  I have searched high and low and can't seem to find anyone else with this need.  I am using the Microsoft Dataverse (legacy) connector.

    ------------------------------
    Heidi Wylie
    CRM Administrator
    PROSOCO
    Lawrence KS
    ------------------------------


  • 2.  RE: Help building a Flow/Power Automate to copy a record

    Posted May 11, 2021 02:32 AM
    Hi Heidi,

    I'm not sure if I fully understand your problem but I give it a try.
    - lookup fields, when you want to create or update a record with lookup fields, then you have to prefix the variable with the entities 'plural name'. So when you have a custom entity with the name apg_processcontrol  you have the following to the variable or value apg_processcontrols(variable)  (mb the parentesis are also necessary)


    - 4 related entitties.... what are those entities.... do youn mean new child records that have to be linked to th newly created project-record? If this is what you want then you have to proceed your flow with a create statement for each of the new children. In these actions you have to use the id from your formerly created project as lookup value to link those records together

    Hopes this helps

    ------------------------------
    Wim Krings
    DevOps Engineer Dynamics 365
    Apg
    Heerlen
    ------------------------------



  • 3.  RE: Help building a Flow/Power Automate to copy a record

    SILVER CONTRIBUTOR
    Posted May 11, 2021 03:56 PM
    Thank you for the response!  I was able to get the lookup values to work just as you said, perfect!

    For the 4 other related records that need to be pulled from the Warranty Record to the newly created Project Record, I think these are considered child records?  As an example, we have Products that should be pulled from the warranty to the project, and sometimes there are multiple products that need to be copied over.  This is why we use the sub-grids for these other 4 related entities.  The products are probably the most difficult one, so I will make an attempt at a simpler one to see if I can get that one to work.

    ------------------------------
    Heidi Wylie
    CRM Administrator
    PROSOCO
    Lawrence KS
    ------------------------------



  • 4.  RE: Help building a Flow/Power Automate to copy a record

    TOP CONTRIBUTOR
    Posted May 11, 2021 02:53 AM
    Edited by Donal McCarthy May 11, 2021 02:54 AM
    When you are populating a lookup, you have to use the the entity set name like below.
    bw_requests(GUID)
    Tip #1311: Use entity name in Flow lookups | Power Platform & Dynamics CRM Tip Of The Day
    Are you also trying to create copies of child records?

    @Wim Krings - just saw that you already posted!

    ------------------------------
    Donal McCarthy
    Digital Marketing Administrator
    BrightWork
    ------------------------------



  • 5.  RE: Help building a Flow/Power Automate to copy a record

    SILVER CONTRIBUTOR
    Posted May 11, 2021 03:58 PM
    I gave that a shot and it works great now!  The next step is figuring out the related records and how to pull them from the sub-grids of my warranty form over to the sub-grids of my projects forms.  I am brand new to using Flow, it's not as intuitive as I'd like it to be but I'm learning.  Thank you for the response!

    ------------------------------
    Heidi Wylie
    CRM Administrator
    PROSOCO
    Lawrence KS
    ------------------------------



  • 6.  RE: Help building a Flow/Power Automate to copy a record

    TOP CONTRIBUTOR
    Posted May 12, 2021 02:46 AM
    Re the Subgrid - the child rows displayed are there because they have a lookup to the Warranty row.
    To get them to appear similarly in the Project row, you need to add a lookup field to the Project in each of the tables.
    Then, you need to run an update record on each of the child rows, and update the lookup here to point at the project row.

    ------------------------------
    Donal McCarthy
    Digital Marketing Administrator
    BrightWork
    Galway
    ------------------------------



  • 7.  RE: Help building a Flow/Power Automate to copy a record

    SILVER CONTRIBUTOR
    Posted May 12, 2021 12:27 PM
    Edited by Heidi Wylie May 13, 2021 12:42 PM
    You mean I would need to add new fields to my Project form?  I'm confused because the sub-grids already exist there, I just need to copy them over from the Warranty record into a new project record.



    This is the flow I have built so far and everything works perfectly.  But now I just can't for the life of me figure out how to copy the sub-grid information over.  I am really stuck on the next step in my flow.  I tried about a dozen different things yesterday before giving up!



    ------------------------------
    Heidi Wylie
    CRM Administrator
    PROSOCO
    Lawrence KS
    ------------------------------



  • 8.  RE: Help building a Flow/Power Automate to copy a record

    TOP CONTRIBUTOR
    Posted May 13, 2021 02:38 AM
    @Heidi Wylie - the reason the records appear in the subgrid is because they have a lookup to the Warranty.
    To get them to appear in the subgrid in the Project, they need to have a lookup to the Project.
    Do you need actually to create new child records, or would reusing the same ones work?
    After all - it all seems related.
    Either way, you need to add the lookup column to the project table to subgrid tables, and populate it with the Project Id: that way they will appear in the subgrid in the Project. I hope that makes sense - it's early here.

    ------------------------------
    Donal McCarthy
    Digital Marketing Administrator
    BrightWork
    Galway
    ------------------------------



  • 9.  RE: Help building a Flow/Power Automate to copy a record

    Posted May 14, 2021 01:27 AM
    @Heidi Wylie - to show the right data in the subgrids is all about the datamodel underlaying the form. In the first form there seems to be a parent-child relationship from Warranty to Warranty Product Family and to Substrates. That means there is a lookup field in the Warranty Product Family and the Substrates table pointing to the Warranty table.
    From the second form it is not clear to me if the same tables are appearing in those subgrids or if that are different tables. If it are the same tables then there should also be a lookup field in those tables, pointing to the Project table. If it are other tables then you should look in those for the lookup field.

    For your Power Automate flow and populating those subgrids:
    - after you create the Project record, you need to retrieve the Warrant Product Family records that are linked to the project. Use a 'List' action. I always use a fetch-xml statement in here that contains the retrieve-logic needed (export an advanced find to fetch-xml or build it in the xrm toolbox).
    - to process all the retrieved records you need an 'Apply to all' loop. This loop will automatically be created if you put an action in that uses a field from the list-result.
    - in the apply loop you have to put in an update or a create action to link the children to the Project record. When your children are already existing records that now also need to be linked to the project record, you need the update action. If it are completely new records, you need the create action.

    hopes this helps to get you a step further ...



    ------------------------------
    Wim Krings
    DevOps Engineer Dynamics 365
    Apg
    Heerlen
    ------------------------------



  • 10.  RE: Help building a Flow/Power Automate to copy a record

    Posted May 12, 2021 11:58 PM
    Edited by Eddie Brown May 13, 2021 12:01 AM
    Wim Krings, thanks for explanation.


If you've found this thread useful, dive deeper into User Group community content by role