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:


  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!


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

      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?


        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.

  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.


    1. If you’re on-prem
      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.


  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

    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.

  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!

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

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


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

  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,

  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,

    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 –


  8. Hey Andrew,
    This is really looking promising, but when I try to configure the Associate Entities step with both the leads, the second Record URL can’t be found. In other words, the (in your example Lead) entity doesn’t show up in the list of related entities in the form assistant.
    Anything I’m forgetting here?

    Thanks and regards,

    1. Nah, never mind. For some reason the results of the first step (the entityreference) didn’t save. After re-entering, saving and trying again, it worked like a charm.

      Again, thanks for all your good work!

  9. Hi Andrew,
    Could this system also be used to distribute an action (with an Entityreference, which is necessary) to _unrelated_ entity records, based on the FetchXml Query field? Or does it have to be associated?

    I created the action exactly how you described, created the request in the calling workflow and filled in “Request”, “Action Name” and “FetchXml Query” fields in the Distribute Action parameters. Yet, nothing happens. The FetchXml is tested correctly so I’m suspecting the Distribute paramaters. If I’d enter the Record field, the job fails because of no relationship name was entered.

    Any thoughts?

      1. Just great! I wasn’t sure if I should contact you because there must be an obvious error in my configuration. And, when creating my screendumps, it showed… (prefix of action wasn’t my standard prefix so without checking I referred to a non-existing action)

        Sorry to have disturbed.

  10. Hello Andrew,
    Reading through all your ideas and the comments, I was wondering if it’d be possible to update multiple fields (using several requests?) and the Update Records bulk operation. What would that look like?


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.