You should always use Option instead of Enum, unless …. (In AL and Business Central)
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”.
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;
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?
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.