So, this came about in a recent discussion. When you have a Two Options field in Dynamics, what’s the point of marking it a business required field?
Let’s start by looking at how you create this field. When you add a new Two Options field, the screen to define it looks like the screenshot below:
Observe that, when you define the field properties, the values are by default Yes and No (you can actually edit and change these), but all the way to the bottom right, you are defining the default value. That means that, no matter what you do, the field will have a default value as defined here. And that works just fine, in particular, when a user creates a record. The selected default value is populated.
Observe though that, at the top right of that form, you have the option to make it a Business Required field.
While that appears to not do anything, other than putting the required red star on the field label, let’s analyze the overall behavior of the record.
So, I’ve added the field to a form, like the screenshot below shows.
Observe that, as soon as the new record form is loaded, the already defined default value is populated. That seems to defeat the purpose of marking the field as Business Required.
Let’s look at another scenario. With the current configuration, let’s get the import template for this entity. Fill it in with some new values in the Name field, but leave the Two Options Field blank.
Now, import it back. Observe that, once imported, the default value is already assigned. I’ve tweaked the view to add the Two Options Field column so we can clearly see the result.
And just to confirm, if you open one of the records, you will get the unfilled field with the default value.
Next scenario, with data generated programmatically. I’ve created a quick plugin triggered by the creation of an Account record. This plugin simply creates a new record in my custom entity.
Once I’ve enabled it and created an account, a new record is created. This one also with a default value where no value was set in the plugin code.
Similarly, if you try Business Rules you are presented with the default value selected, and no choice to clear it.
So, the conclusion is that, short of trying an integration scenario which will most likely have similar results, all the presented scenarios demonstrate that on an Two Option field, the ability to mark it Optional or Business Required does not affect the behavior. It’s there probably for consistency with the other field types, but does not affect the standard functionality. The answer to the question in the title would be never.
There’s another gotcha with a Two Options field, and that relates to it’s use in Business Process Flows. Marking it Business Required will not stop the user from advancing to the next step, as it’s always going to have a value populated, as just demonstrated.
Oh, and note that with the new streamlined web interface from v9 onward, the Two Radio Buttons presentation style is now a regular field changing the value on click. None of the old round radio buttons any more (nostalgia setting in, anyone?).
Note: These tests were run on a V9 instance.
Leave a Reply