How to add checkBox to Dialog and get value?

I want to add CheckBox to my Dialog .

I used this code:

Dialog dialog; DialogField dialogField; NoYesId checkValue; ; dialog = new Dialog("New dialog with checkBox"); dialogField = dialog.addFieldValue(identifierStr(NoYes) , checkValue); checkValue= dialogField.value(); dialog.run(); info(strfmt("Value %1" , checkValue)); 

So, in Debug, I see the value of the variable (checkValue) is always NO.

In the web tutorial, I saw this code:

 dialog.addFieldValue(typeid(NoYes), NoYes::Yes, "tip"); 

But I have an error. The typeid method does not exist.

How? Thanks everyone

enjoy it!

+6
source share
3 answers

You can use typeId (AX 2009 and earlier) or extendedTypeStr (AX 2012) for extended data types (EDT), rather than listing as NoYes . It can be used on NoYesId since it is an EDT.

 dialog.addFieldValue(typeid(NoYesId), NoYes::Yes, "Check"); 

You must call run before you can meaningfully get the value.

 Dialog dialog = new Dialog("New dialog with checkBox"); NoYesId checkValue = NoYes::No; DialogField dialogField = dialog.addFieldValue(extendedTypeStr(NoYesId), checkValue, "Check it"); if (dialog.run()) { checkValue = dialogField.value(); info(strfmt("Value %1" , checkValue)); } 
+8
source

You can use enumStr() if the extended data type does not exist for an enumeration, for example:

 dialogField = dialog.addFieldValue(enumStr(NoYes), checkValue); 
+1
source

id Str instead of extendedTypeStr worked for me (Ax 2012)

-1
source

Source: https://habr.com/ru/post/988500/


All Articles