I am writing an integration that imports a purchase order from an XML file using the C# eConnect library.
When I attempt to include inventory items as purchase order line items, I am told that the vendor item has not yet been set up. I would therefore like to create these vendor items before the purchase order is created.
Problem is, when I serialize the eConnect transaction to XML including both the POPTransactionType (containing the purchase order) and the IVItemMasterType (containing the new vendor items), I still get the error message that the vendor item doesn't exist.
POPTransactionType eConPo = new POPTransactionType() { taPoHdr = poHead, taPoLine_Items = poLines }; IVItemMasterType eConIv = new IVItemMasterType() { taCreateItemVendor_Items = vendorItems }; eConnectType eConType = new eConnectType() { IVItemMasterType = new IVItemMasterType[] { eConIv }, POPTransactionType = new POPTransactionType[] { eConPo } }; XmlSerializer serializer = new XmlSerializer(eConType.GetType()); using (StringWriter sw = new StringWriter()) { using (XmlWriter writer = XmlWriter.Create(sw)) { serializer.Serialize(writer, eConType); } return sw.ToString(); }
This results in the following XML.
<?xml version="1.0" encoding="utf-16"?> <eConnect xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema"> <POPTransactionType> <eConnectProcessInfo xsi:nil="true" /> <taRequesterTrxDisabler_Items xsi:nil="true" /> <taUpdateCreateItemRcd xsi:nil="true" /> <taUpdateCreateVendorRcd xsi:nil="true" /> <taCreateVendorAddress_Items xsi:nil="true" /> <taUpdateCreateCustomerRcd xsi:nil="true" /> <taCreateCustomerAddress_Items xsi:nil="true" /> <taPopIvcTaxInsert_Items xsi:nil="true" /> <taPopDistribution_Items xsi:nil="true" /> <taAnalyticsDistribution_Items xsi:nil="true" /> <taPoLine_Items> <taPoLine> </taPoLine> <taPoLine> </taPoLine> </taPoLine_Items> <taPoHdr> </taPoHdr> </POPTransactionType> <IVItemMasterType> <eConnectProcessInfo xsi:nil="true" /> <taRequesterTrxDisabler_Items xsi:nil="true" /> <taUpdateCreateItemRcd xsi:nil="true" /> <taUpdateCreateItemCurrencyRcd_Items xsi:nil="true" /> <taIVCreateItemPriceListLine_Items xsi:nil="true" /> <taIVCreateItemPriceListHeader xsi:nil="true" /> <taItemSite_Items xsi:nil="true" /> <taCreateItemVendors_Items> <taCreateItemVendors> </taCreateItemVendors> <taCreateItemVendors> </taCreateItemVendors> </taCreateItemVendors_Items> <taCreateKitItemRcd_Items xsi:nil="true" /> <taCreateInternetAddresses_Items xsi:nil="true" /> </IVItemMasterType> </eConnect>
Does eConnect process these transactions in sequence? If so, then it looks like the POPTransactionType is processed first. This will obviously cause an error because the IVItemMasterType has not yet run, setting up the vendor item records.
I would prefer to run this in a single transaction rather than two separate transactions if there is some way to ensure the vendor items are set up prior to the purchase order being raised?
*This post is locked for comments