How to instantiate System.Bool

tarkmylertarkmyler Member Posts: 57
edited 2014-07-23 in NAV Three Tier
Howdy,

I'm building an interface to a (foreign to NAV) web service that requires a boolean value in one of the request elements. I'm working in NAV 2013r2 with a C# wrapper around the web service. Acceptable values are shown below:

IsASpecialOrder - Null = don't apply any filter - gets special and regular orders at the same time.
IsASpecialOrder - True = Only get special orders.
IsASpecialOrder - False = Only get regular orders.

If I alter the C# wrapper so that the value cannot be null, (which C/Side likes), it is sent with a false value during the request. If I can instantiate a dotnet boolean (mscorlib) variable and then assign it to the webservice boolean value I might be able to get around this.

However, when I try to address a System.Bool variable in C/Side it complains that it isn't instantiated. Any ideas?

#-o
Mark Tyler
Pacific City, OR

Comments

  • Torben_R.Torben_R. Member Posts: 99
    How about using an integer from NAV and let the C# wrapper translate it?

    Like
    0 = you send a null
    1 = FALSE
    2 = TRUE
  • tarkmylertarkmyler Member Posts: 57
    That is one way to approach this, but it seems like I'm missing something simple.

    I have a COM version of this code that runs in 2009r2. It uses that approach (side-step C/Side and do the heavy lifting externally). What I lose is the direct communication with the web service. I'm actually calling the web service and reading the response in NAV 2013r2 C/Side code. In the COM object, I set values in vb.net that are exposed as Public Properties, and then use those values when I call a Public Function called "DownloadOrders". It issues the request to the (same) web service and writes records directly to the NAV SQL dB using System.Data.Linq.DataContext. I wasn't too concerned about how it worked in version 6 because it has an end-of-life that is known, (big no no in the NAV world to write directly to the dB).

    However, I was hoping to park that code at the door in NAV 2013r2 and go directly to the web service. As advertised here http://msdn.microsoft.com/en-us/library/hh165619(v=nav.71).aspx , where it shows a direct mapping between System.Bool and a C/Side Boolean. When you define a variable ("flag") as System.Boolean.'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' and attempt to assign it a value, NAV says "Assignment is not allowed for this variable". Then when I try something like:

    flag.Equals(TRUE);

    During execution you get "A DotNet variable has not been instantiated. Attempting to call System.Boolean.Equals in Codeunit XYZ:OnRun"

    So if you try to instantiate (below) by calling the constructor...

    IF flag.Boolean() THEN;

    You get a really hairy C/Side message that I'm not even going to document.

    Just saying... isn't this supposed to work?
    Mark Tyler
    Pacific City, OR
Sign In or Register to comment.