enum name and value to the label

When you have name of the enum and you know integer of the value that you want to display.

dictEnum dictEnum;

dictEnum = new DictEnum(enumName2Id(“NoYes”));
info( strFmt(“%1”, dictEnum.index2Label(1)));


When you have enum name and name value but want to have an int

Some part of code where taken from https://community.dynamics.com/ax/f/33/t/86432

I was looking for this little piece of code for too long to let it go.

So pretty much this code can be helpful. Enjoy

 Common common;

DictEnum dictEnum = new DictEnum(enumName2Id(“NoYes”));

info(int2str(dictEnum.name2value(“No”)));//<– that is label, not the name of the field

Change amount of visible elements on the form depending on selected record.

I was creating form and regarding on the value of the record, I had to add or remove specific form elements ( fields and etc. )

The most convenient place to do that is on a data source, in method Active. It is possible that you have to try few data sources and decide which one suits you more.

Although this doesn’t work during initialization of the form. When you open the form it gathers 0 instead of actual record value.