How to add checkBox in Dialog and get value?
Asked Answered
H

3

8

I want to add a CheckBox in 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) always NO .

On web-tutorial I saw this code:

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

But I have an error Method typeid not exist .

What is the way? Thanks all,

enjoy!

Headsman answered 4/6, 2015 at 8:5 Comment(0)
O
12

You can only use typeId (AX 2009 and before) or extendedTypeStr (AX 2012) on extended data types (EDT), not enums like NoYes. It can be used on NoYesId, as it is an EDT.

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

You must call run before you can meaningful acquire 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));
}
Observable answered 4/6, 2015 at 8:19 Comment(0)
C
4

You can use enumStr() if extended data type does not exists for enum, e.g:

dialogField = dialog.addFieldValue(enumStr(NoYes), checkValue);
Constituency answered 3/12, 2016 at 18:8 Comment(1)
Thanks @Aliaksandr Maksimau, nice advice.Headsman
S
0

identifierStr instead of extendedTypeStr worked for me (Ax 2012)

Sutler answered 19/8, 2016 at 13:57 Comment(1)
This will cause a best practice warning "Consider use of more specialized intrinsic functionality"Constituency

© 2022 - 2024 — McMap. All rights reserved.