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
Answers
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.
unfortunately I am doing exactly this:
what results in this
:-(
Regards
Markus
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,
Thomas
sounded really good but does not work either:
Debugger:
Best regards
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,
Thomas
What type of object is "cims:value". If it is not of datatype Boolean, obviously FORMAT(...,9) will not have the desired effect here.
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!