I'm trying to create sales orders using the /IDORequestService/ido/update/{ido} web service interface. I'm populating the order header IDO and also including 'NestedUpdates' for the line item data. The system responds with a successful response. The order header has been created, but the lines are not there. No error messages. Any ideas?
I'm trying to use the nested updates so that the whole order is created inside a transaction.
Trimmed code looks like this:
IDOUpdateItem idoItem = new IDOUpdateItem{ Action = UpdateAction.Insert, ItemID = "PBT=[SLCoAlls]", UpdateLocking = UpdateLocking.Property};
idoItem.Properties.Add(new IDOUpdateProperty("CoNum", "H000000001", true));idoItem.Properties.Add(new IDOUpdateProperty("SiteRef", "Default", true));idoItem.Properties.Add(new IDOUpdateProperty("CoAllCurrCode", "USD", true));idoItem.Properties.Add(new IDOUpdateProperty("CustPo", "PO-Test", true));idoItem.Properties.Add(new IDOUpdateProperty("CustNum", "CustNumber", true));idoItem.Properties.Add(new IDOUpdateProperty("CustSeq", 0, true));
IDOUpdateItem lineData = new IDOUpdateItem(UpdateAction.Insert);lineData.Properties.Add(new IDOUpdateProperty("CoNum", "H000000001", true));lineData.Properties.Add(new IDOUpdateProperty("SiteRef", "Default", true));lineData.Properties.Add(new IDOUpdateProperty("Item", "ItemIdValue", true));lineData.Properties.Add(new IDOUpdateProperty("UM", "EA", true));lineData.Properties.Add(new IDOUpdateProperty("QtyOrdered", 3, true));
IDOUpdateItems lines = new IDOUpdateItems();lines.Add(lineData);
UpdateCollectionRequestData linesData = new UpdateCollectionRequestData{ IDOName = "SLCoitemAlls", RefreshAfterUpdate = true, Items = lines};
linesData.SetLinkBy("CoNum", "CoNum", "SiteRef", "SiteRef");
idoItem.NestedUpdates.Add(linesData);
listUpdateItems.Add(idoItem);
UpdateCollectionRequest request = new UpdateCollectionRequest { Changes = listUpdateItems };string contentStr = JsonConvert.SerializeObject( request );
//Console.WriteLine( contentStr );
HttpResponseMessage response = client.PostAsync(requestUrl.ToString(), new StringContent(contentStr, Encoding.UTF8, "application/json")).Result;
Hi Henrik Bruun,
I have never used C# to do what you are trying to do but make sure the Customer Order is created/added before you attempt to populate the lines. Your issue might just be that.
Other cloud ERP systems allows you to create a complete order in a transaction, by sending the order header and line data in a single POST. I was hoping the IDO interface allowed that too, to avoid partial order creations in the case of failures during line item inserts. Single call allows the system to roll the whole thing back in the event of failures.
Syteline treats the Header (Customer Orders) separately from the Lines (Customer Order Lines). The header can exists even if there no Lines attached to it. The Lines cannot be added if the Header does not exists.