How to instantiate System.Bool

tarkmyler
Member Posts: 57
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
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
Pacific City, OR
0
Comments
-
How about using an integer from NAV and let the C# wrapper translate it?
Like
0 = you send a null
1 = FALSE
2 = TRUE0 -
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, OR0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions