Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Bulk create orders

Posted on by Microsoft Employee

Is it possible to bulk create orders with the same customer details? 

*This post is locked for comments

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Bulk create orders

    What value do you have in salesorderguid?

    Also make sure that the Guid is not inside quotes if you are using a variable.

    Entity orderFROM = crmService.Retrieve("salesorder", new Guid("12345678-1234-1234-1234-123456789012"), new ColumnSet(true));

    or

    string salesorderguid = "12345678-1234-1234-1234-123456789012";

    Entity orderFROM = crmService.Retrieve("salesorder", new Guid(salesorderguid), new ColumnSet(true));

    Hope this helps.

  • Linkedin Profile Picture
    Linkedin 155 on at
    RE: Bulk create orders

    Hello 

    I  embedded your function on my plugin but I am receiving exception at this line:

    Entity orderFROM = crmService.Retrieve("salesorder", new Guid("salesorderguid"), new ColumnSet(true));

    System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
    Please advise.
    Thanks for anticipation.
    Eman Abed AlWahhab
  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Bulk create orders

    Hi M.trieu19,

    if you solved the problem thanks to an answer, please mark it as verified to encourage the community to provide more and more a better support. Thank you. Francesco

    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

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Bulk create orders

    Hi M.trieu19,

    use the following coe:

    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 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, ITALY

    Independent Contractor

    http://www.francescopicchi.com

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Bulk create orders

    You could probably add a Command Bar button (using Ribbon Workbench) in the Account entity (for customer) called Create Order. On the click of a button you can call an Action, Workflow or WebApi (via JavaScript) that will create a new order with the details of the Account that you specified.

    Whatever account you call this from would create the same data for the Order with the exception of the account name.

    Alternatively, you can create a web resource that would open on the order form, where the user would select an account, and you would call one of the processes above to create the order.

    There are other options, but I think one of these would work for your needs.

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Bulk create orders

    Hi,

    The user wants to create multiple orders which contains the same data input in the fields. The only thing different would be the order number.

    I'm not too sure what other information you need...

    Thanks,

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Bulk create orders

    Hi M.trieu19,

    please provide more detail about the flow, your description is poor of details.

    Thanks

    Francesco

    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, 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans