Navision Automation Sequences

Microsoft Dynamics Navision has the ability to call into DLL files and receive events from them which can be very handy indeed, if not a necessity. But sometimes it can also be a bit of a kludge to work with. Native datatypes can sometimes be more flexible than Navision datatypes or you cannot easily transport data from an automation into Navision.

As a simple example, there is the .Net string class. It can hold arbitrarily large strings (as machine constraints permit), but it is not able read in these large strings as Navision strings can only be 1024 characters max. There is a Navision BigText, but it isn’t possible to use that in this case.

Of course the problem doesn’t stop with strings. It is very handy to read in large collections of things into Navision. So what to do?

Well for my part I made a thin wrapper around the Microsoft .Net Framework IEnumerator type, called the INavEnumerator. It can’t be type-parametric as that is not supported by .Net/COM infrastructure. The INavEnumerator has the Reset method, so it can be rerun just as is possible with IEnumerator. The INavEnumerator is just a COM interop wrapper, the methods are the same.

   1:      [Guid("cdf70d50-e790-47ae-908d-e3d8bcbe2b17")]
   2:      [ComVisible(true)]
   3:      public interface INavEnumerator
   4:      {
   5:          /*
   6:           * Set the enumerator to its initial position, before the first element.
   7:           */
   8:          [DispId(0x4001)]
   9:          void Reset();
  11:          /*
  12:           * Go to the next position and return whether it has a value.
  13:           */
  14:          [DispId(0x4002)]
  15:          bool MoveNext();
  17:          /*
  18:           * The current element of the enumerator.
  19:           */
  20:          [DispId(0x4003)]
  21:          Object Current { get; }
  22:      }
  24:      [ClassInterface(ClassInterfaceType.None)]
  25:      [ComVisible(true)]
  26:      public class NavEnumerator : INavEnumerator
  27:      {
  28:          public IEnumerator Delegate
  29:          {
  30:              get;
  31:              set;
  32:          }
  34:          public void Reset()
  35:          {
  36:              Delegate.Reset();
  37:          }
  39:          public bool MoveNext()
  40:          {
  41:              return Delegate.MoveNext();
  42:          }
  44:          public Object Current
  45:          {
  46:              get { return Delegate.Current; }
  47:          }
  48:      }



About xosfaere

Software Developer
This entry was posted in Uncategorized and tagged , , , , , , , , . Bookmark the permalink.

One Response to Navision Automation Sequences

  1. xosfaere says:

    By the way, this code was used to good effect to get a nice programmatic interaction with .Net in an SMTP/POP3 assembly developed with a colleague.

    See her blog here:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s