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;
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.