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.
...in this case invoking a transactional IDO method (one transaction, rollback all changes upon error) would be the solution...not sure whether one already exists (out-of-the-box), otherwise you could create one - if you have development capabilities in the SL ERP...
Are you firing this code in the client tier in form or global script, or are you firing it within the context of an IDO method?
If you're doing this in an IDO method, you can submit the update using Context.Commands.UpdateCollection(). You can then set the IDO method as transactional in the IDO methods form.
I'm doing this in a web service call and using update collection. I'm now using two different IDOs (SLCos and SLCoitems) , but results are the same, meaning not working.
Have you been able to create the CO Header?
yes, I can call and create a header and then make a second call to create line items. The problem is that leaves it wide open to problems if something goes down between those two calls. other cloud system APIs allow for that to occur in a single web service call with both header and detail records populated.