1

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.

good-to-know
  • 742
  • 3
  • 15
  • 32
  • 1
    You need to add more details about expected and actual behavior – G. Stoynev Jun 08 '15 at 13:47
  • What type of details you need? I believe I'd given all to my knowledge. – good-to-know Jun 08 '15 at 14:22
  • Perhaps you can specify if the item you're showing exists and is being updated or you know you're inserting it for the first time. Are there any logs on the server side showing the result of the operation? It is likely that you're not following the expected protocol of the Update/Insert or you're lacking permissions. The more you share, the greater the abbility for someone to replicate and/or see the issue. – G. Stoynev Jun 08 '15 at 17:35

2 Answers2

0

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

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

Ol' Dawg
  • 71
  • 2
0

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

good-to-know
  • 742
  • 3
  • 15
  • 32