How to send enum types from TXdataWebClient

Hi,

Question:

I call the xdata service like this

TAwait.Exec<TXDataClientResponse>(dmWebModule.xdataclntWebClient.RawInvokeAsync('IDansoftWEBService.checkWEBL',[dmtWEBT]));

the service parameter dmtWEBT is a enum type

TDeviceMT =
    (
      dmtWEB,
      dmtWEBT
    );

from xdata perspective the service looks like this

function checkWEBL(const moduletype: TDeviceMT): Boolean;

I see that payload from the xdata client for the paramater dtmWEBT is 1 and I get an error … but when I send this parameter as string "dmtWEBT" is ok.
How can I add info to the TXdataWebClient to serialize enum to string?
How is proper way to call xdata services with enum types?

Yes, you should send the name of the enum, not the number. And you can do just like you would do in Delphi, using unit TypInfo:

EnumName := GetEnumName(TypeInfo(TDeviceMT), dmtWEBT);
TAwait.Exec<TXDataClientResponse(
  dmWebModule.xdataclntWebClient.RawInvokeAsync(
    'IDansoftWEBService.checkWEBL',[EnumName]));
1 Like

Thank you ... I added Ord and now is working

GetEnumName(TypeInfo(TDeviceMT), Ord(dmtWEBT))