web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to clone records in CRM 365

(0) ShareShare
ReportReport
Posted on by 5,514

business process is going to be deprecated pretty soon so need an alternative way. We have a need to clone opportunity records in CRM 365.

*This post is locked for comments

I have the same question (0)
  • sandeepc Profile Picture
    5,514 on at

    Any suggestions will be marked as verified

  • Verified answer
    Community Member Profile Picture
    on at

    There's 3rd party tool called Snapshot from Cobalt to clone the record along with its relationships. But it doesn't work for N:N relationships.

  • sandeepc Profile Picture
    5,514 on at

    is there any solution like workflow javascript??

  • Verified answer
    Community Member Profile Picture
    on at

    Hi sandeepc,

    please provide more details, like:

    1) you need to clone records by plugin / workflow so you are asking for a c# method?

    2) you need to clone it by javascript?

    3) Something else?

    Looking forward for these information.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    33,628 on at

    Hi,

    Here is what you can do.

    1. write your own plugin / workflow / console tool.

    2. purchase a third party solution.

  • sandeepc Profile Picture
    5,514 on at

    hi picchi

    yes, we were cloning records from workflow in previous 2013 crm. is that possible similarly without 3rd party tool or it is required ?

    yes in javascript how it is possible?

  • Verified answer
    Community Member Profile Picture
    on at

    Hi sandeepc ,

    use the following code inside a custom workflow or plugin.

    Please note this example will clone a salesorder with all related salesorderdetail; you need to adapt it to your entity:

    Entity orderFROM = crmService.Retrieve("salesorder", new Guid("salesorderguid"), new ColumnSet(true));
    
    Entity orderTO = new Entity("salesorder");
    
    foreach (KeyValuePair<string, object> attr in orderFROM.Attributes)
    {
        if (attr.Key == "statecode" || attr.Key == "statuscode" || attr.Key == "salesorderid" || attr.Key == "ordernumber")
            continue;
    
        orderTO[attr.Key] = attr.Value;
    }
    
    Guid orderTOguid = crmService.Create(orderTO);
    
    QueryByAttribute query = new QueryByAttribute("salesorderdetail");
    query.ColumnSet = new ColumnSet(true);
    query.Attributes.AddRange("salesorderid");
    query.Values.AddRange(orderFROM.Id);
    List<Entity> orderdetailFROMlist = crmService.RetrieveMultiple(query).Entities.ToList();
    
    List<Entity> salesorderdetailTO = new List<Entity>();
    
    foreach (Entity orderdetailFROM in orderdetailFROMlist)
    {
        Entity orderdetailTO = new Entity("salesorderdetail");
        foreach (KeyValuePair<string, object> attr in orderdetailFROM.Attributes)
        {
            if (attr.Key == "salesorderid")
                continue;
    
            orderdetailTO[attr.Key] = attr.Value;
        }
    
        orderdetailTO["salesorderid"] = orderFROM.Id;
    
        crmService.Create(orderdetailTO);
    }

    Please let me know if you solve.

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • sandeepc Profile Picture
    5,514 on at

    I have few doubts/questions left.

    I need to clone Notes/comments in Case

    I need to Clone Booking Forecast,Sales Team(Opportunity and related entities) in Opportunity

    and i need to do it using C#(Plugins) is that possible if yes how??

    Any suggestions will be marked as verified

  • sandeepc Profile Picture
    5,514 on at

    Any suggestion pls

  • Verified answer
    Community Member Profile Picture
    on at

    Hi sandeepc,

    yes, you can close anything using the posted code, you only need to adapt code to entity types.

    Have you got some doubts? SDK can do everything :-)

    If you found the answer helpful, please mark as Verified 

    Join my network on LinkedIn      Follow me on Twitter 

    Thank You & Best Regards

    Francesco Picchi

    Microsoft Dynamics CRM Consultant, Bologna+Milano, ITALY

    Independent Contractor

    http://www.francescopicchi.com

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans