Unit price is not updating while create items on eConnect

578 views Asked by At

I was using eConnect to connect my .NET application to the Dynamics GP. This is my C# eConnect code to create/update an item on Dynamics GP.

taUpdateCreateItemRcd GpLineItem = new taUpdateCreateItemRcd();
GpLineItem.ITEMNMBR = "iPartNumber";
GpLineItem.ITEMDESC = "iDescription";
GpLineItem.CURRCOST = 50.65;
GpLineItem.ITMCLSCD = "classID";
GpLineItem.ITEMTYPE = 1;
GpLineItem.Purchase_Tax_Options = 2;
GpLineItem.UOMSCHDL = "EACH";
GpLineItem.UpdateIfExists = 1;

IVItemMasterType ivMasterType = new IVItemMasterType();
ivMasterType.taUpdateCreateItemRcd = GpLineItem;

IVItemMasterType[] ivMasterTypeArray = { ivMasterType };
eConnectType eConnect = new eConnectType();
eConnect.IVItemMasterType = ivMasterTypeArray;

// Serialize the master vendor type in memory.
MemoryStream memoryStream = new MemoryStream();
XmlSerializer xmlSerializer = new XmlSerializer(eConnect.GetType());


// Serialize the eConnectType.
xmlSerializer.Serialize(memoryStream, eConnect);

// Reset the position of the memory stream to the start.              
memoryStream.Position = 0;

// Create an XmlDocument from the serialized eConnectType in memory.
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.Load(memoryStream);
memoryStream.Close();

// Call eConnect to process the XmlDocument.
eConnectMethods.CreateEntity(connectionString, xmlDocument.OuterXml);

When I checked the xmlDocument, I have only these below fields.

<?xml version="1.0"?><eConnect xmlns:xsi="www.w3.org/.../XMLSchema-instance" xmlns:xsd="www.w3.org/.../XMLSchema">
<IVItemMasterType>
    <eConnectProcessInfo xsi:nil="true" />
    <taRequesterTrxDisabler_Items xsi:nil="true" />
    <taUpdateCreateItemRcd>
        <ITEMNMBR>iPartNumber</ITEMNMBR>
        <ITEMDESC>iDescription</ITEMDESC>
        <ITMCLSCD>RETAIL</ITMCLSCD>
        <UOMSCHDL>EACH</UOMSCHDL>
    </taUpdateCreateItemRcd>
    <taUpdateCreateItemCurrencyRcd_Items xsi:nil="true" />
    <taIVCreateItemPriceListLine_Items xsi:nil="true" />
    <taIVCreateItemPriceListHeader xsi:nil="true" />
    <taItemSite_Items xsi:nil="true" />
    <taCreateItemVendors_Items xsi:nil="true" />
    <taCreateKitItemRcd_Items xsi:nil="true" />
    <taCreateInternetAddresses_Items xsi:nil="true" />
</IVItemMasterType>
</eConnect>

I have no idea, what's wrong in my code. Please help me in this. All your help is much appreciated. Thanks.

2

There are 2 answers

0
good-to-know On BEST ANSWER

Answered by Tim Wappat

You must "specify" that you are supplying some fields, current cost is one of those.

See the class description in the eConnect Programmers Guide (search for CURRCOSTSpecified).

I think it would be something like:

GpLineItem.CURRCostSpecified = true;

as another line in your code where you are setting the class members of the taUpdateCreateItemRcd.

We've all done it at some time...

0
Ol' Dawg On

I believe you have to add this line: GpLineItem.CURRCOSTSpecified = true;

With eConnect, you have to do this with a lot of values.