Hi,
I'm using eConnect to connect my .net application to the Dynamics GP. Below is code I use to create an item.
private void CreateSOPItem() { using (eConnectMethods eConnectMethods = new eConnectMethods()) { taUpdateCreateItemRcd itm = new taUpdateCreateItemRcd(); itm.ITEMNMBR = "ITEM-DUMMY-CHECK"; itm.ITEMDESC = "Item description"; itm.ITMGEDSC = "Generic description"; itm.ITMCLSCD = "RETAIL"; itm.ITEMTYPE = 1; itm.UOMSCHDL = "EACH"; itm.UpdateIfExists = 1; itm.CURRCOST = 50; itm.CURRCOSTSpecified = true; itm.Purchase_Tax_Options = 2; itm.Purchase_Tax_OptionsSpecified = true; IVItemMasterType iv = new IVItemMasterType(); iv.taUpdateCreateItemRcd = itm; IVItemMasterType[] myIV = { iv }; eConnectType eConnect = new eConnectType(); eConnect.IVItemMasterType = myIV; // 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); } }
The item has been successfully inserted into the GP system. Now I use the below code to create a Sales Order for this item, and got an error.
private void CreateSalesOrder() { try { using (eConnectMethods eConnectMethods = new eConnectMethods()) { SOPTransactionType salesOrder = new SOPTransactionType(); taSopLineIvcInsert_ItemsTaSopLineIvcInsert salesLine = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert(); taSopHdrIvcInsert salesHdr = new taSopHdrIvcInsert(); taSopLineIvcInsert_ItemsTaSopLineIvcInsert[] LineItems = new taSopLineIvcInsert_ItemsTaSopLineIvcInsert[1]; var nextSONum = new GetNextDocNumbers().GetNextSOPNumber(IncrementDecrement.Increment, "STDORD", SopType.SOPOrder, connectionString).Trim(); salesLine.CUSTNMBR = "PLAZAONE0001"; salesLine.SOPTYPE = 2; salesLine.DOCID = "STDORD"; salesLine.QUANTITY = 2; salesLine.ITEMNMBR = "ITEM-DUMMY-CHECK"; salesLine.UNITPRCE = 50; salesLine.XTNDPRCE = 100; salesLine.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy"); LineItems[0] = salesLine; salesOrder.taSopLineIvcInsert_Items = LineItems; salesHdr.SOPTYPE = 2; salesHdr.DOCID = "STDORD"; salesHdr.BACHNUMB = "B1"; salesHdr.DOCDATE = System.DateTime.Today.ToString("MM/dd/yyyy"); salesHdr.CUSTNMBR = "PLAZAONE0001"; salesHdr.SUBTOTAL = 100; salesHdr.DOCAMNT = 100; salesHdr.USINGHEADERLEVELTAXES = 0; salesHdr.PYMTRMID = "Net 30"; salesOrder.taSopHdrIvcInsert = salesHdr; eConnectType eConnect = new eConnectType(); SOPTransactionType[] MySopTransactionType = new SOPTransactionType[1] { salesOrder }; eConnect.SOPTransactionType = MySopTransactionType; // 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); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
Below is my error.
Sql procedure error codes returned: Error Number = 771 Stored Procedure= taSopLineIvcInsert Error Description = Price Level is blank, it must either be passed in or a default must exist for the transaction Node Identifier Parameters: taSopLineIvcInsert SOPNUMBE = ORDST2267 SOPTYPE = 2 Related Error Code Parameters for Node : taSopLineIvcInsert PRCLEVEL = Note: This parameter was not passed in, no value for the parameter will be returned. Error Number = 1599 Stored Procedure= taSopLineIvcInsert Error Description = The UOFM for the item is not specified in the Item Price List as a Default Selling UofM Node Identifier Parameters: taSopLineIvcInsert SOPNUMBE = ORDST2267 SOPTYPE = 2 Related Error Code Parameters for Node : taSopLineIvcInsert UOFM = Note: This parameter was not passed in, no value for the parameter will be returned. Error Number = 5313 Stored Procedure= taSopLineIvcInsert Error Description = Unit of Measure does not exist for the Unit of Measure Schedule being used Node Identifier Parameters: taSopLineIvcInsert SOPNUMBE = ORDST2267 SOPTYPE = 2 Related Error Code Parameters for Node : taSopLineIvcInsert NONINVEN = Note: This parameter was not passed in, no value for the parameter will be returned. UOFM = Note: This parameter was not passed in, no value for the parameter will be returned. <taSopLineIvcInsert> <SOPTYPE>2</SOPTYPE> <CUSTNMBR>PLAZAONE0001</CUSTNMBR> <DOCDATE>06-16-2015</DOCDATE> <ITEMNMBR>ITEM-DUMMY-CHECK</ITEMNMBR> <UNITPRCE>50</UNITPRCE> <XTNDPRCE>100</XTNDPRCE> <QUANTITY>2</QUANTITY> <DOCID>STDORD</DOCID> <SOPNUMBE>ORDST2267</SOPNUMBE> </taSopLineIvcInsert>
Please tell me how can I fix this error. I'm very new to Dynamics GP and eConnect, and I expect solution in eConnect (aka. C# Code).
If I use some sample item number, like "3-B3813A". It works, this error occurred only for the newly created item. :(
A huge thanks in advance.
*This post is locked for comments
This is the working code to create Price Levels. Thanks Soma.
private void CreatePriceLevel(string ItemPartNumber)
{
try
{
using (eConnectMethods eConnectMethods = new eConnectMethods())
{
IVCreateItemPriceListType priceListType = new IVCreateItemPriceListType();
taIVCreateItemPriceListLine_ItemsTaIVCreateItemPriceListLine priceLine = new taIVCreateItemPriceListLine_ItemsTaIVCreateItemPriceListLine();
taIVCreateItemPriceListHeader priceHdr = new taIVCreateItemPriceListHeader();
taIVCreateItemPriceListLine_ItemsTaIVCreateItemPriceListLine[] LineItems = new taIVCreateItemPriceListLine_ItemsTaIVCreateItemPriceListLine[1];
priceLine.ITEMNMBR = ItemPartNumber;
priceLine.PRCLEVEL = "RETAIL";
priceLine.UOFM = "EACH";
priceLine.UpdateIfExists = 1;
priceLine.CURNCYID = "Z-US$";
LineItems[0] = priceLine;
priceListType.taIVCreateItemPriceListLine_Items = LineItems;
priceHdr.ITEMNMBR = ItemPartNumber;
priceHdr.PriceGroup = "PHONE";
priceHdr.UOFM = "EACH";
priceHdr.PRCLEVEL = "RETAIL";
priceHdr.CURNCYID = "Z-US$";
priceHdr.UpdateIfExists = 1;
priceListType.taIVCreateItemPriceListHeader = priceHdr;
eConnectType eConnect = new eConnectType();
IVCreateItemPriceListType[] MyItemPriceListType = new IVCreateItemPriceListType[1] { priceListType };
eConnect.IVCreateItemPriceListType = MyItemPriceListType;
// 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);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Try the below. Maybe this (taIVCreateItemPriceListLine ) name will differs. Correct it if this give any other name while typing your projects.
private void CreateItemPriceList()
{
try
{
using (eConnectMethods eConnectMethods = new eConnectMethods())
{
IVCreateItemPriceListType priceList = new IVCreateItemPriceListType();
taIVCreateItemPriceListLine priceLine = new taIVCreateItemPriceListLine();
taIVCreateItemPriceListHeader priceHeader = new taIVCreateItemPriceListHeader();
taIVCreateItemPriceListLine[] LineItems = new taIVCreateItemPriceListLine[1];
priceLine.ITEMNMBR = "PLAZAONE0001";
priceLine.CURNCYID = "AED";
priceLine.PRCLEVEL = "RETAIL";
priceLine.UOFM = "EACH";
priceLine.TOQTY = 999999999999.00000;
priceLine.UOMPRICE = 50;
LineItems[0] = priceLine;
priceList.taIVCreateItemPriceListLine = LineItems;
priceHeader.ITEMNMBR = "PLAZAONE0001";
priceHeader.PRICMTHD = 1;
priceHeader.PriceGroup = "DEFAULT";
priceHeader.UOFM = "EACH";
priceHeader.PRCLEVEL = "RETAIL";
priceList.taSopHdrIvcInsert = priceHeader;
eConnectType eConnect = new eConnectType();
IVCreateItemPriceListType[] MyIVCreateItemPriceListType = new IVCreateItemPriceListType[1] { priceList };
eConnect.IVCreateItemPriceListType = MyIVCreateItemPriceListType;
// 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);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Hope this helps!!!
Hi Soma,
Yes, I was creating the eConnect schema like I did on creating Sales Order. Once I got it working, I'll post that code here so that other who have the same issue can be benefited.
P.S: I'll mark your answer as the verified answer. Thanks for you all done. :)
Hi Mohammed,
I don't have any sample source code for the item price list. But, you can use the above mentioned eConnect schema to setup the same by the way you are using sales order.
Note: Please mark it as verified, if this answer your question. Because this will helps to some others who experience the same.
Hope this helps!!!
Hey Zeba,
I'm not interested in using VKonnact, or other third party libraries. Sorry.
Hi Soma,
Thanks. I got it working after set up a price list for the newly created item through cards > Inventory > Price List
So the solution is now finalized. However I cannot set up a price list for every new item via said method in GP system. All I have to do is via code.
You also suggested some class name IVCreateItemPriceListType. Can you please write some sample code like I wrote in the question?
Thanks a trillion in advance. :)
VKonnact provides with the facility to integrate data from various sources into Microsoft Dynamics GP without writing a single line of code. To know more about VKonnact visit http://www.vkonnact.com/
Additionally, if you have setup the default UofM and Price Level in Item Price List window you no need to pass the values.
Go to cards-->Inventory--Price List and setup the price list for the newly created item.
Or
Use the below eConnect schema to setup the same by using your coding.
IVCreateItemPriceListType
(line-->taIVCreateItemPriceListLine and header-->taIVCreateItemPriceListHeader)
Hope this helps!!!
Hi Mohammed,
There are some required fields missing in your Sales order creation coding. You need to pass the UofM & Price Level.
Hope this helps
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156