You should always use Option instead of Enum, unless …. (In AL and Business Central)
Tag Archives: Option
Business Central API – Filter Child Array Values Using $filter Query Option
I had a difficult time finding an example of this type of API filtering using the OData $filter query option, so I wanted to share an example that I needed for a project.
For context, this is a very simple example of a Business Central API “child array” that I wanted to filter. Technically, I think that OData calls this an “expanded navigation property”.
It’s time to Enumify your Options
In this video, I demonstrate how you can “upgrade” your Option fields to Enums in Microsoft Dynamics 365 Business Central. I show how to can get rid of some of the bad patterns we have accepted with option fields.
Options VS Enums
To define a variable of type Option, you can’t use the OptionMembers property that’s used on a field of data type Option. You need to list the available options as a comma-separated list after your variable definition.
For example:- Color: Option Red,Green,Yellow;
Tip #67 | Convert Option field to Enum Field
Today I was working on our ForNAV AppSource App and I decided to clean up some of the warnings that were introduced with BC16. This was about converting Options to Enums and vice versa.
Converting an Enum into an Option is easy. Just add ToInteger() and you’re done. But how about the other way around?
Source : Mark Brummel Blog | Microsoft Dynamics NAV
Read more…
Enum != SchemaChange
The biggest showstopper we had in the old days with C/Side to separate code was the option field. Option fields are often where modules get together and programmers make switches in the code about which business logic to execute.
The CredentialQuery Option For Web.Contents() In Power BI Custom Data Connectors
There’s a new, as yet undocumented, option for the Web.Contents() M function that is only available for custom data connectors and not in Power BI Desktop: CredentialQueryOption. It does the same thing as the Query option, but it stops the values you are passing to the query parameter from being logged in Power BI’s diagnostic logs, so it’s useful if you are passing sensitive information such as passwords.