Blog, Tools, Ultimate Workflow Toolkit

UWT: Cloning record with related records with no code

After I wrote previous post regarding copying of N-N related records I got reasonable question – why have I used Action in this scenario if it is possible to implement it without it using just “Distribute Workflow” step and On-Demand workflow. I agreed that this is possible. So here is other scenario that can’t be implemented without additional Action and “Distribute Action” step – cloning of record with N-N related records.

Let’s use the same Lead and Industry entities and implement cloning of Lead with copying of related Industries into destination entity.

Create “Industry” related action:

Add “Entity Reference” input with “Lead” as a target entity:

After that add “UWT: N-N Operations: Associate Entities” step from Ultimate Workflow Toolkit:

and configure it:

set “Record 1 Reference” to “Url” for Industry, “Record 2 Reference” to “Url” for Lead and “Relationship Name” to name of relationship between “Lead” and “Industry” (uwt_industry_lead) in my case.

Activate Action and close it.

Create “Lead” related workflow:

Remove all triggers and mark is as “On Demand” workflow.

Add “Create Record” Lead step and map fields you want to be cloned:

With the next step start the preparation of special “Request” object that will be used in further steps – add a “UWT: Request Builder: Set Lookup Field” step to workflow:

and then configure it:

where “Field Value” is a reference to “Cloned” lead created on first step of workflow, “Field Name” – name you give to “Lead” Input from Action you created on step 1. Leave “Request” field blank – it is used when you have multi-step population of fields of “Request” object.

The next step is to add “UWT: Bulk Operations: Distribute Action” step to workflow:

Here is how you need to configure it:

Set “Request” to “Modified Request” output of “Set Lookup field” step, populate “Action Name” with “Unique Name” of Action you created in a first part, pass “Url” of “Lead” for which workflow is executed (and not one that was created in it) and set “Relationship Name” to uwt_industry_lead. Save and Activate your workflow.

So that’s it – let’s check it in action:

17 Comments on “UWT: Cloning record with related records with no code

  1. Hi Andrew,
    Is there by any chance an documented example of how to configure UWT for “Update records”/”Set Lookup Field”? I just can’t seem to get it working.
    Thanks a million in advance!

    Regards,
    Jeroen

    1. Hello Jeroen,
      Unfortunately I don’t have it documented. What’s your scenario?
      Thanks,
      Andrew

      1. Hi,
        It’s one that has a thousand possiblities to solve, but I really want to understand the way your Request builder does it’s work.

        Our accounts have an custom accountnumber. The number generator we used to use wasn’t very good, resulting in quite a few double generated numbers.

        First, I want to identify all doubles. Created a lookup field to account, called “Twin”, on the account entity in which I’d like to see the other account with the same accountnumber.

        The mission now is to get this Twin field filled where ever possible so I’d like to do a bulk update from account to account where the accountnumber is the same but the accountid isn’t, setting the Twin lookup.
        (sure hope this makes any sense)

        Anything I can accomplish using your Update records function?

        Thanks!
        Jeroen

        1. Jeroen,
          It makes perfect sense but I don’t think workflows is the best way to go. I would recommend to ask Microsoft to provide a backup of your SQL DB, restore it somewhere and use T-SQL to get your duplicates – it’s much easier.
          Andrew

  2. Fortunately I don’t need MS for that (yet) since we’re still on premise. Definately much easier, I just thought that this was a nice opportunity to get to know UWT a bit better.

    Jeroen

    1. If you’re on-prem
      Select
      accountnumber
      From FilteredAccount a
      Group By accountnumber
      Having Count(*) > 1

      will give you the list of all the duplicated account numbers.

      I believe for every single task it’s better to use appropriate tool. In this case – SQL and tSQL are your best friends.

      Andrew

  3. Yeah, thanks, but I had that way covered already. Just really wanted to play around with UWT.

    Could you sketch me a typical situation in which you’d use Update Records with a Set Lookup Field request?

    thanks a lot
    Jeroen

    1. Jeroen,
      Here is scenario – let’s imagine that for accounts/contacts lookups are used for country/city fields and based on the internal rules when one of those fields is updated on account the same updates should happen to child contacts for an account. Using “Update Records” step it’s possible to implement that scenario.
      Andrew

  4. Hey Andrew,
    In this scenario I was expecting that I should be building a Lookup Field Request with Field Value being dynamic value of the changed field and the Field Name being the schema name of the target field in contact. Next Bulk Operations: Update Records which refers to the Request. Unfortunately the workflow fails at the first step so obviously I’m doing something wrong or incomplete (incomplete would be my best guess).

    What am I missing here?

    Thanks a million!
    Jeroen

    1. Jeroen,
      Everything looks correct. Can you please demonstrate a screenshot of your step and log of the error?
      Andrew

  5. By all means, but this editor won’t let me paste in any screenshots. Any other method/media I can reach you by?

    Thanks!
    Jeroen

    1. Jeroen,
      You can store your screenshot on some external hosting and leave url here.
      Andrew

  6. Ik knew it would be something that easy 😉
    White smoke over here, so thank you very much on sticking with me. I’ve got my working example to go and explore more.

    Best regards,
    Jeroen

  7. Hi Andrew,

    I see here you are creating new N-N relationship, but what about N:1? I want to clone opportunity products from opportunity – the cloning of the opportunity works, but in the process log it says that the relationship is not N-N and the child products do not clone – what is the workaround?

    Best Regards,
    Venci

    1. Hello Venci,

      That should work fine as well. Here are steps to implement cloning of opportunity products using UWT:

      1. Create an action regarding “Opportunity Product” entity.
      2. Add a “Lookup” parameter pointing to “Opportunity” entity.
      3. Use “Create Opportunity Product” step from UWT and populate required fields combining data from Target Opportunity Product and “Opportunity”.
      4. Save and publish action.
      5. Create a workflow that will do the main work.
      6. Inside that workflow create an opportunity.
      7. Use “Request Builder” step to set the lookup parameter to newly created opportunity.
      8. Use “Distribute Action” from “Bulk Operations” to distribute action created on the step 1 across Opportunity Products of current opportunity.

      Here is the whole thread where I tried to help to build scenario similar to yours – https://community.dynamics.com/365/sales/f/dynamics-365-for-sales-forum/371439/workflow-to-create-opportunity-and-add-associated-product-lines/981741#981741

      Thanks,
      Andrew

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.