I like when I do upgrades to my Dev box to go through the error list warnings to see what has been made obsolete or deprecated on code that we have custom on
Some of the warnings I get are:
1) Warning Comparing a numerical value with extensible enum 'Extensible Enumeration(PriceDiscProductCodeType)' will yield unexpected results. Extensible enum values are not deterministically assigned to a numerical value.
2) Warning Cast from extensible enum 'Extensible Enumeration(SalesStatus)' to 'int' potentially harmful and deprecated.
3) Warning Cast from extensible enum 'Extensible Enumeration(EcoResReleaseProductToCompany)' to 'int' potentially harmful and deprecated.
The above warnings are on code that looks correct to me and I have seen it used exactly the same in standard code. So why do I get the warning.
For example:
1) Extension: "if (!discAdmSearchCustomer.AccountRelation && discAdmSearchCustomer.AccountCode == PriceDiscPartyCodeType::Table)" generates the warning mentioned in (1).
If you look in standard code PriceDiscAdmSearch.procesCust(), you will see it is used exactly like in my extension:
Standard:
i"f (!discAdmSearchCustomer.AccountRelation && discAdmSearchCustomer.AccountCode == PriceDiscPartyCodeType::Table)
{
return;
}"
2) In my data entity postload() method I have:
"
SysDictEnum SalesStatusEnum = new SysDictEnum(enumNum(SalesStatus));
this.SalesStatus = SalesStatusEnum.value2Label(salesTableLocal.SalesStatus);"
In https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/system-classes/dictenum-class, one should use dictenum::Value2Label. However intelliSence is only showing DictEnum::Value2Id.
So how should I write the code to get rid of the warning?
3) My custom:
itemCreateArgs = new Args();
itemCreateArgs.record(ecoResProduct);
itemCreateArgs.parmEnumType(enumNum(EcoResReleaseProductToCompany));
itemCreateArgs.parmEnum(EcoResReleaseProductToCompany::Yes);
If you look in standard form: RetailAffiliationPriceGroup, method jumpRef(), you will see that parmEnumType is being used exactly like my custom:
Args args = new Args();
args.parmEnumType(enumNum(RetailDiscountOfferTypeBase));
args.parmEnum(enum2int(RetailPeriodicDiscount.PeriodicDiscountType));
Any suggestions on how to get rid of these warnings is much appreciated