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.
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:
as another line in your code where you are setting the class members of the taUpdateCreateItemRcd.
We've all done it at some time...