Enum2Str Conversion

Hi All,

I’m using asp.net as front end and AX as back end. I’m retrieving data from AX by using business connector.

We are using the Address Master in AX for storing customer addresses.

The AddressType is an Enum field, as you all know.

Now, while retrieving it from dot net am recieiving the Enum values like 1, 2, 3 and not the string values of it like Home, Delivery, etc…

I want to know how i can convert these enum to str in the dotnet front… Because, though i tried it in AX side, while retrieving the string values are not populated.

The code am using in AX is,

AddressType 7;

str Addr;

;

7 = AddressType::MailingAddress;

Addr = enum2str(7);

I want to know, how to do this at dotnet end.

Thanks!

it seems right.

does mailingaddress have labels?

Did a quick job

static void testEnum(Args _args)
{
AddressType AType;
str Addr;
;
AType = AddressType::Invoice;
Addr = enum2str(AType);
info(Addr);
}

And that sucessfully sets Addr to the swedish label “Faktura”

But does your method compile with variable-name 7?

No… it is not working nor numerals before 10…

but luckily it works for 1.

I don’t know, why this is happening. Is this a bug in product or what i don’t know.

Can u plz tell me hw i can retrieve the string value of enum in dotnet?

Are you trying from the outside or from the inside.

In the first post you write that the code sample is “The code am using in AX is…”

Are you trying to pickup the enum on the outside or sending a string from ax instead of an enum.

Sorry if I’m a bit slow today. Early morning here and soon weekend :slight_smile:

Yeah… I’m retrieving datas from asp.net

I’m just selecting the records from addr table using a query. but this addrtype column alone doesnt give me the string field.

It is having values like 13, 14, 7, etc…

But in AX everything is perfect.

Hope u got my question now.

I want the Addrtype field to have direct string values like Home, Physical Address, Mailing Address etc (while retrieving from .net)

That’s okay… enjoy your weekend:)

Now I’m on track. Will get back to you.

Former posted about creating a axaptaobject of the enum. That won’t work I remembered.

yeah… even i have read those posts… but it is not about retrieving enum values as string. its about hiding or removing one or two enum elements.

Hi Jayanthi,

U can use, this.CurrentRow.GetFieldValue().ToString, to get the value of field as string.

To get code for CurrentRow, u can see the standard pages.

Even, u can put ur Enum in proxy and use that in .net, as we use that in X++.

I hope it helps…

Dear

i have created the form and in this form i waht to filter the data based on selecting the enum, i have written code in the execute query but its not work and not fetch date in to the form. i have also written enum change mathod and there write the code to execute query

Please suggest me what to do?

public void executeQuery()

{

pendrecv pend,none,recv;

;

pend = pendrecv::Pending;

none = pendrecv::Empty;

recv = pendrecv::Received;

qb = this.query().dataSourceTable(tablenum(VendInvoiceJour)).findRange(fieldnum(VendInvoiceJour,purchid));

if (!qb)

if(manualstatus.valueStr() == enum2str(pend))

{

qb = this.query().dataSourceTable(tablenum(VendInvoiceJour)).addRange(fieldnum(VendInvoiceJour, purchid));

qb.value(sysquery::valueNotEmptyString());

qb = this.query().dataSourceTable(tablenum(VendInvoiceJour)).addRange(fieldnum(VendInvoiceJour, accountinvid));

qb.value(sysquery::valueEmptyString());

}

else if(manualstatus.valueStr()==enum2str(none))

{

qb = this.query().dataSourceTable(tablenum(VendInvoiceJour)).addRange(fieldnum(VendInvoiceJour,ledgervoucher));

qb.value(sysquery::valueEmptyString());

}

else if(manualstatus.valueStr()==enum2str(recv))

{

qb = this.query().dataSourceTable(tablenum(VendInvoiceJour)).addRange(fieldnum(VendInvoiceJour, purchid));

qb.value(sysquery::valueNotEmptyString());

qb = this.query().dataSourceTable(tablenum(VendInvoiceJour)).addRange(fieldnum(VendInvoiceJour, accountinvid));

qb.value(sysquery::valueNotEmptyString());

}

super();

}

public boolean modified()

{

boolean ret;

VendInvoiceJour_ds.executeQuery();

ret = super();

return ret;

}

You should probably look at the \Forms\InventQuarantineOrder