ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

AL0603 - Implicit conversion from Enum to Integer

Open andreilungu opened this issue 5 years ago • 11 comments

1. Describe the bug When use subpage part in a page and have Enum in the Subpage Link we receive error:

An implicit conversion is being performed from a value of type 'Integer' to a value of type 'Enum "Default Dimension Parent Type"'. This conversion can lead to unexpected runtime issues. This warning will become an error in a future release.AL(AL0603)

part(defaultDimensions; "APIV1 - Default Dimensions") { Caption = 'Default Dimensions'; EntityName = 'defaultDimension'; EntitySetName = 'defaultDimensions'; SubPageLink = ParentId = Field(SystemId), "Parent Type" = const(1); }

"Parent Type" = Enum "Default Dimension Parent Type"

How can we solve this issue considering we can not use "Parent Type".AsInteger() or use the Enum Value instead of const(1).

andreilungu avatar Nov 12 '21 11:11 andreilungu

Why do you think you can't use the enum name in the SubPageLink? It should be perfectly possible. What did you try? What problem did you see?

dzzzb avatar Nov 12 '21 11:11 dzzzb

Oh, it was just as simple as: SubPageLink = ParentId = Field(SystemId), "Parent Type" = const(Customer);

I tried in other ways, but did not check this one.. Seems to work. Can be closed, sorry

andreilungu avatar Nov 12 '21 11:11 andreilungu

Yes, and if the enum value name contains spaces, just enclose it all in "", e.g. "Parent Type" = const("Some Enum Value Name")

dzzzb avatar Nov 12 '21 11:11 dzzzb

What about this case?

in an XML Port we have:

tableelement("Reservation Entry"; "Reservation Entry") { LinkFields = "Source Subtype" = FIELD("Document Type"), "Source ID" = FIELD("Document No."), "Source Ref. No." = FIELD("Line No."); LinkTable = "Sales Line"; MinOccurs = Zero; XmlName = 'reservationentry'; UseTemporary = true; fieldattribute(sourcetype; "Reservation Entry"."Source Type") { } }

"Source Subtype" in table "Reservation Entry" is still an option.

"Document Type" is Enum "Sales Document Type".

So I get warning: An implicit conversion is being performed from a value of type 'Enum "Sales Document Type"' to a value of type 'Option'. This conversion can lead to unexpected runtime issues. This warning will become an error in a future release.AL(AL0603)

This appears also in standard, table 900 "Assembly Header" field(48; "Reserved Quantity"; Decimal) { CalcFormula = Sum("Reservation Entry".Quantity WHERE("Source ID" = FIELD("No."), "Source Type" = CONST(900), "Source Subtype" = FIELD("Document Type"), "Reservation Status" = CONST(Reservation))); Caption = 'Reserved Quantity'; DecimalPlaces = 0 : 5; Editable = false; FieldClass = FlowField; }

Will the "Source Subtype" be converted to Enum?

andreilungu avatar Nov 12 '21 16:11 andreilungu

"Will the "Source Subtype" be converted to Enum?" Don't know transferring to app teams. They may know

kalberes avatar Nov 15 '21 15:11 kalberes

You can use #pragma statements for such cases

AlexanderYakunin avatar Nov 16 '21 07:11 AlexanderYakunin

I used #pragma first but then I thought if it would be better to leave the warning and get it fix without #pragma when you fix it in the base app.

The question is if you have a timeline for fixing this? If it will not be in the next version, then I will use #pragma in our code..

andreilungu avatar Nov 16 '21 07:11 andreilungu

We have a similar behaviour in the CalcFormula of some FlowFields.

Specefically we relate the sales/purchase "Document Type" (Enum) with the "Source Subtype" of the Warehouse Activity documents (Options). The option field must be changed to Enum, can you change it in a future release?

TriangleSPV avatar Nov 16 '21 09:11 TriangleSPV

We have no plans to convert Source Subtype to Enum. This field is Integer in many places (and this is correct design) and Option on some other places (and this is legacy issue we cannot fix in easy way). We will keep this as is until we have less breaking option to do this kind of changes.

AlexanderYakunin avatar Nov 19 '21 13:11 AlexanderYakunin

Hi Alexander. You didn't get it right. I mean to the field "Source Subtype", which is an option to relate to the different document types. As you said, the "Source Type" is related to the table number and it is correct.

TriangleSPV avatar Nov 20 '21 11:11 TriangleSPV

Of course, my comment was about Source Subtype. Corrected above.

AlexanderYakunin avatar Nov 20 '21 14:11 AlexanderYakunin