Gracefully dealing with eConnect errors

If you need to integrate with Microsoft Dynamics GP one of the options you may choose is to use the eConnect product. eConnect is an API that allows you to submit XML documents to Dynamics GP to perform CRUD operations on most of the document types in GP. Using .NET for integrations, if any issues/problems arise from submissions to eConnect,  via eConnect_EntryPoint or eConnect_Requester methods, then these errors are surfaced as eConnect exceptions. The .Message property of this class contains the error text.

The econnectException class returns the message from the eConnect stored procedure that originated the problem. A table of these messages is held in SQL server, DYNAMICS database, table taErrorCode. This table gives an idea of the error conditions you may not have thought possible and lets you be a bit more proactive at handling errors.

ta_ErrorCode To see the contents of this table see this file:

Item does not allow back orders

Lets choose an example problem that you may experience. When submitting a SOP sales order document, normally you want any items that are out of stock to be back ordered. This is easy, set the QtyShrtOpt = 4 in the XML to back order the balance. However if you have a situation where you have a telesales team hammering in orders as well as a website taking orders, even with SQL replication you can occasionally get a scenario where a web order comes in for an item that has been set to disallow web orders and it no longer has enough stock to satisfy the web order. This may be due to latency in updating stock on the website for example. eConnect lets us know with the following exception: “Microsoft.GreatPlains.eConnect.eConnectException: Error Number = 4776”

Gracefully dealing with it

There a few ways I can think of to deal with this, the chosen one is to change the QtyShrtOpt = 6 for the line in question inorder to cancel the qty that can not be allocated from stock. It is wise to then set an order note to let the sales staff who will process the order know about the issue so it can be resolved with the customer, perhaps alternative item offered.

.NET code

A regular expression is used to parse the eConnect exception text. This allows easy detection of what error has occurred and extracts the item number for the order line raising the exception.

  1. Dim ItemNumberList As New List(Of String)
  2. 'Get the item numbers that exhibit this error
  3. For Each CurrentMatch As RegularExpressions.Match In _
  4.     RegularExpressions.Regex.Matches(ErrorText, _
  5.         "(<taSopLineIvcInsert>.*<ITEMNMBR>(.*)</ITEMNMBR>.*</taSopLineIvcInsert>) --->.*Error Number = 4776", _
  6.         RegularExpressions.RegexOptions.Singleline)
  7.     If CurrentMatch.Groups.Count > 1 Then
  8.         'capture 2 has the itemnmbr
  9.         ItemNumberList.Add(CurrentMatch.Groups(2).Value.Trim)
  10.     End If
  11. Next CurrentMatch

Having a list of item numbers with this issue allows us to change the XML of the document being submitted to alter the quantity shortage option flag to cancel the balance (option 6). Promoting LINQ for XML work, load the XML document into a XDocument (LINQ XML Document) class.

  1. Dim salesdoc As XDocument = XDocument.Parse(xmlSalesOrder.OuterXml)

Now use a LINQ query to get all the elements that need the backorder option changing and change it to 6.

  1. For Each CurrentItem In ItemNumberList
  2.     Dim CurrenItemVar As String = CurrentItem
  3.     For Each CurrentElement As XElement In From salesline In salesdoc.Elements.Descendants("taSopLineIvcInsert") _
  4.                     Where salesline.Element("ITEMNMBR").Value.StartsWith(CurrenItemVar) _
  5.                     Select salesline
  6.         CurrentElement.SetElementValue("QtyShrtOpt", "6")
  7.     Next
  8.     salesdoc.Elements.Descendants("taSopHdrIvcInsert")(0) _
  9.       .SetElementValue("NOTETEXT", _
  10.         salesdoc.Elements.Descendants("taSopHdrIvcInsert")(0).Element("NOTETEXT").Value & vbCr & String.Format( _
  11.         "Item: {0} could not be fully ordered due to no back order allowed flag set on item and lack of stock.", CurrenItemVar))
  12. Next
For each item fixed, the XML of the document we are submitting has order notes appended to take account of the fact there is an issue with this item. The sales are already always reading the order notes for customer comments coming through from the website so should catch these notes.

Now the altered XML document is resubmitted to Dynamics GP via eConnnect. If it fails this time there is an issue that we have not programmed for so it needs administrative intervention.

To load the xDocument back into the XMLDocument class for submission to eConnect,

  1. xmlSalesOrder.Load(salesdoc.CreateReader())

Note on security

Beware exposing your ERP system to your website – if the website gets compromised, then so is your business. eConnect allows most of your business data to be altered and queried - this is something to be very careful of. With the implementation I created, the XML document is punched through the firewalls to a custom web service on the GP segment of the network. This web service only lets through the specific eConnect documents we want to allow through and only those that meet specific criteria to limit the attack potential.


By adding to this example, common errors your eConnect integration encounters could be eliminated so IT staff are prevented from spending time supporting disruptive day to day integration issues. Thus these problem cases are handed back to the process owner, be that; buyers, warehouse, or sales staff.

Windows snipping tool

Type “Snipping” in to Windows 7 start bar


Select snipping tool from the list

Snipping Start Menu View

You can now make window screen grabs or freehand screen grabs using this tool.

Snipping Tool View

Taking a screenshot of a drop down menu with the snipping tool

However you get stuck when you want to take a screen shot of a menu item like a right click menu or drop down program menu. In this case the snipping tool can be activated by pressing [CTRL] & [Prnt Scrn] together. This then switches on the screen grab mode of the snipping tool and you can snip away! Obviously you have to launch the Snipping Tool before it will let you active the screen grab with this key shortcut.

Windows 7 users (even XP if you install it from download at Microsoft)

You should look at the Problem Steps Recorder (type “psr” into your start menu). This tool will take a continuous run of screen grabs as you execute a process and at the end you may save them to a zip file. Ideal for use in documentation for a process in an application or computer.

“Disable Script” option greyed out in IE developer tools

I found this problem the other day, debugging a site I set the disable script option on the developer toolbar to check for none JavaScript browser support. Then later I wanted to use other sites as normal but found that all JavaScript was still disabled. Opening the developer tools, the option was greyed out in the developer tools of Internet Explorer thus I was unable to get JavaScript running again in the browser. I asked around the office to find others had seen this but never worked out how to fix it.

Disable script greyed out

I went experimenting, what I discovered was that this option is only available if the current site has trust. Try adding the site into trusted sites or Intranet under I was back in business.

Set the options in Internet Options

Tools>Internet Options>Security>Tusted Sites, Sites button, Add.

internet options

You MUST refresh the page for this to take effect.

The script option is available again. This was even though this site was on our intranet. Thus the automatic detection of Intranet sites in our scenario is not adequate.

Diable script option available

Watch out for directories called “POPUP”

One of our designers made an error today, placing images they wanted to appear in a directory called “POPUP”. We use the JavaScript library Lightbox to give smooth popup images for products in the website, so popup in that sense was appropriate.

The anti-virus solution we have has advertising blocking in it. This software running on the client machines blocked the functionality of the page. Thus making it useless.

After consulting me as to what the problem was, a lesson was learnt.


Don’t use directories names that sound like spam on your websites!