Thursday 18 October 2018

Referencing an Option Set in a Flow condition step

20:48 Posted by Benitez Here , , , , , No comments
A field type that can be referenced in a Dynamics 365 workflow condition step is an Option Set. As defined in the https://docs.microsoft.com site:
This field provides a set of options. Each option has a number value and label. When added to a form, this field displays a control for users to select only one option.
In Dynamics 365 workflows we are used to configuring a condition step in a clicking manner when referencing an Option Set.

How do I replicate this in Flow?

Welcome to another WTF blog post where I share with you how to replicate this in Flow.

Two Dynamic Contents to choose from

When referencing an Option Set in Flow through a Dynamics 365 connector, there will be two options (no pun intended) presented to you. 


1. This will reference the number values of the options in the Option Set
2. This will reference the the labels of the options in the Option Set

Using Dynamic Content No.2

This is displayed as <field name> Label in the Dynamics Content selector. In my scenario, I see Priority and Priority Label.

Selecting Priority Label is a valid approach as it allows you to configure the Flow condition step by entering the label of  an option such as "VIP" in the criteria of the expression.

Why this is useful

If the person configuring the Flow is not familiar with customizing Dynamics 365 they will only know of the options displayed in the Option Set field through their regular interactions with the field on a daily basis. You simply navigate to the field, then click on the Option Set field to see the options that can be selected. 

Why this is not useful

Using the Priority Label will not safeguard the Flow from future changes to the label of the option. As seen in my vlog, if I were to change VIP to Very Important, the Flow will not pass the expression of the Flow condition step the next time it is executed. This is due to the Flow condition step being told in the expression that the Priority Label criteria must be VIP, not Very Important.

Using Dynamic Content No.1

Priority is another valid approach in the Flow condition step when the trigger is a Dynamics 365 connector. Rather than using the label of the option the number value will be used instead.

When using the number value in Flow, the commas need to be removed. If you leave the commas of the number value after copying from the field configuration record in Dynamics 365 and pasting into Flow the expression will fail. So remove the commas!

NOTE: If using CDS connector you will only be able to use Priority in your expression. 

Why this is useful

If in the future the label value changes, such as from VIP to Very Important, the Flow condition step will continue to pass the expression because the number value is used, rather than the label.

Why this is not useful

The person configuring the Flow is required to know the number values of the options in the Option Set fields. The person may not know or have the required access to view the option set number values. However one could argue that only certain users in Dynamics 365 or CDS would only ever be allowed to configure workflows in the first place, therefore would have a security role that would provide them with the ability to do so.

Summary

If you are restricted to using the Dynamics 365 connectors because you don't have a Flow Plan 1 or Plan 2 to use CDS connectors, recommend to use the Dynamic Content that will reference the number values of the options in the Option Set instead of the Dynamic Content that will reference the labels in a Flow condition step. This way if the label is changed in the future, the Flow condition step will continue to execute as the number values are being referenced.

If you use a CDS connector as a trigger for the Flow, then you can only use the Dynamic Content that will reference the number values of the options in the Option Set.

Whether it is Dynamics 365 connector or a CDS connector, you will need to know the number values of the Option Set for your Flow condition step. This requires access to viewing the Field configuration record in Dynamics 365 or in CDS.

0 comments:

Post a Comment