Dynamics 365 Business Central and Power Automate: conditions on empty field values

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_ .

Why this?

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…

2 Comments

  1. Hi Stefano, thank you for sharing this. When I create a flow, I cannot use _x0020_ , but instead, I use ” (double single-quote). It gave me incorrect if-condition result when I put: salesperson is.equal.to _x0020_ . But when I use salesperson is.equal.to ”, the if-condition result is correct. I use API category: v2.0. Do you know that _x0020_ and ” will serve the same purpose?

    Like

    1. SalesPerson Code is not an enum value, so ” or empty value is correct.
      If the field is an enum value (like Blocked for example) and you want to test the value Blocked::” “, you should use _x0020_

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.