In the past days I’ve received the following question from one of my followers: in a Power Automate workflow, how can I test if a Business Central entity field is blank?
Immediately after reading the question, my first answer was: oh, but that’s very easy… but after thinking a bit, I remember that there are also some tricky parts to know about these cases. And this is the reason of why I’ve decided to share this quick post.
Normally, when you need to test if a Dynamics 365 Business Central field is empty, in Power Automate you can omit the value of the field.
As an example, let’s consider a Power Automate flow triggered when someone modify a Customer record in my Dynamics 365 Business Central environment. When the flow is triggered, I need to retrieve the record and I need to test if the SalesPerson Code field is blank in order to take actions.
The flow can be defined as follows:
Here the workflow checks is the SalesPerson Code is blank (no value). If the condition is true it goes on the left branch, otherwise it goes on the right side. Quite easy…
But what about if I need to test also for another field and in this case the field is an enum value? Leaving the value field empty is not correct in this case.
Let’s consider for example that the new condition to test on my flow should be if the Customer record has Blocked = blank (customer not blocked) or if the SalesPerson Code field is blank.
The correct way to write the following condition in Power Automate is as follows:
Here, the empty value for an enum field is translated into _x0020_ .
Some API pages, including most API v2.0 pages, have fields based on AL Enum objects. Fields based on AL enum objects must have names that are consistent and always the same, so that filters on the report always work (no matter the language or operating system you’re using). For this reason, the fields based on AL enums aren’t translated and are encoded to avoid any special character, including the space. In particular, whenever there’s an empty option in the AL Enum object, it’s encoded to “_x0020_“. This is the Unicode encoded representation of a space.
This rule applies to all other Microsoft products (Power BI, Power Apps, Sharepoint APIs and more) so please remember it, it can help on save you time…