Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

Create Vendor Items at the same time as Purchase Order - eConnect

Posted on by 115

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

  • Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: Create Vendor Items at the same time as Purchase Order - eConnect

    If my mind serves me correctly, in the taPOLine XML node, you have the UpdateIfExists flag. When set to 1, it should allow you to update not just the lines on the PO, but also the vendor item number on the item card, which should negate the need for instantiating the item entity.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans