Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Trying to add new orders with existing products

$
0
0

Hello,

I'm new with the Dynamics CRM and i'trying to create 100 orders through a console application. I managed to create the orders with unique names but now I am stuck with adding products to the orders. (I'm coding in C# in Visual Studio with the Dynamics SDK) Below is a code snippet that creates an order with the orderdetails, the products should be added through the orderdetails.

var order = new SalesOrder()
                    {
                        Name = "order" + orderNum,
                        ShippingMethodCode = 1,
                        ShipTo_City = "city",
                        ShipTo_ContactName = "name",
                        ShipTo_Line1 = "street" + houseNum,
                       // PriceLevelId = new CrmEntityReference("Prijslijst", new Guid()),
                        Id = new Guid(),
                        SalesOrderId = new Guid?(), 
                        
                    };

                    ctx.AddObject(order);
                    ctx.SaveChanges();

                    var orderDetail = new SalesOrderDetail()
                    {
                        Id = new Guid(),
                        SalesOrderId = new CrmEntityReference("salesorder",order.SalesOrderId.Value),
                        // references to products in dynamics CRM
                    };
                  
                    ctx.AddObject(orderDe


I want to reference in salesorder to an already created pricelist in Dynamics CRM and in SalesOrderDetail i want to add some products that are located on Dynamics CRM. 

I hope someone can help me with this.


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>