Force Boolean value to be "true" or "false", instead of "Yes" or "No"

MarHan
Member Posts: 34
Hi community,
I need to write a boolean value to an xml file and am always getting a "Ja" (German for Yes), instead of a "true". I've tried all of the options shown here under "Standard Boolean Format" (Link) but without success. And I don't wanna do stuff like "if value = 1 then 'true' else 'false'" or so.
Does anyone have a clue for me?
Thanks in advance,
Markus
I need to write a boolean value to an xml file and am always getting a "Ja" (German for Yes), instead of a "true". I've tried all of the options shown here under "Standard Boolean Format" (Link) but without success. And I don't wanna do stuff like "if value = 1 then 'true' else 'false'" or so.
Does anyone have a clue for me?
Thanks in advance,
Markus
0
Best Answer
-
What are you doing? Do you compose an XML document as Text? Don't! Use an XmlPort or XML DOM Management Codeunit or whatever else is available in your environment to properly generate XML documents.
What type of object is "cims:value". If it is not of datatype Boolean, obviously FORMAT(...,9) will not have the desired effect here.0
Answers
-
Hi,
You have to use FORMAT(Value,0,9) to get XML-formatted value.
This applies not only to Boolean, but also to the Int, Decimal, and Date data types.0 -
Hi,
unfortunately I am doing exactly this:
what results in this
:-(
Regards
Markus
0 -
Hello,
I'd try it with (temporarily) changing the language setting (https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-globallanguage-method). Change the language to english before formatting the value, then back to the original language. Pseudo code:
OriginalLanguageId := System.GlobalLanguage();
System.GlobalLanguage(1033); // change to english
FormattedBooleanValue := FORMAT(BooleanVariable, 0, 9);
System.GlobalLanguage(OriginalLanguageId); // change back
Best Regards,
Thomas0 -
Hi Thomas,
sounded really good but does not work either:
Debugger:
Best regards
Markus
0 -
Hi Markus,
I'm not working in AL yet, but C/AL ... I made a short test:
So, the language change doesn't help (yielding 'Yes'), but XML format by specifying 9 works...
This is just wild guessing: I think you are using a table field as the parameter for the Format function. Maybe in AL it works different for a field object compared to a plain boolean variable?
Best Regards,
Thomas0 -
What are you doing? Do you compose an XML document as Text? Don't! Use an XmlPort or XML DOM Management Codeunit or whatever else is available in your environment to properly generate XML documents.
What type of object is "cims:value". If it is not of datatype Boolean, obviously FORMAT(...,9) will not have the desired effect here.0 -
Hi vaprog,
I'm doing this "manually" as it is a nightmare using XML DOM Mgt Codeunit when you need to deal with different xml namespaces and so on. The xmls have a rather simple structure so much easier and less frustrating.
And you we're absolutely right: Due to a copy and paste mistake my variable "cmis:value" still was a text not a boolean. Having changed it to boolean it works now. Even without the language change that Thomas suggested.
Thanks guys!0
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