Ribbon Workbench display rule-How should a bool value be used?

3.6k Views Asked by At

I am trying to display a button based on a yes/no value. I am using a value rule and have tried 0 and 1, true and false, and InvertResult of nothing.

Does anyone know what the correct value is for assessing a bool? The button should display when the value is true (or not false).

Here is the xml produced and screenshot.

<ValueRule Field="cc_cancloseaswon" Value="Yes" Default="false" InvertResult="false" />

Example


EDIT

The use case is as follows. I have a bool column on the entity to indicate if the button should be visible.

  • When the correct stage of the BPF in entered, a workflow sets the value to true.
  • When other stages are entered in the BPF, a workflow sets the value to false:

I believe it would set the correct visibility when the value is true. Example

The command checker shows it evaluates as false on top of not being visible. Command checker

Level up shows the value is true: Level up attribute checker

I have refreshed to check it has evaluated when the value is definitely set.

2

There are 2 best solutions below

0
On BEST ANSWER

The display rule only evaluates attributes available on the form. true is the correct value for a bool, I just needed to add the attribute to the form.

I assumed it would assess non-table data but the ribbon seems to use formContext.data.entity attributes. This only occurred to me when I started writing a custom rule and it was an easy idea to test. The attribute can of course be hidden on the form if it doesn't otherwise need to be there.

If the attribute is not present on the form, it will evaluate as an empty string ''.

4
On

When comparing a ValueRule use 0 or 1 as values. Example:

<DisplayRule Id="YourDisplayRuleId">
    <ValueRule Field="cc_cancloseaswon" Value="1" />
</DisplayRule>

Also see this article.

Keep in mind in many cases you may need an enable rule instead of a "display rule". Since MS Dynamics 2013 both types of rules hide and show buttons. The main difference is that display rules are evaluated server-side, while enable rules are evaluated client-side. When you need to hide or show buttons as a result of the user's actions on the form, you need to use enable rules, e.g. a CustomRule calling a JavaScript function on the form returning a boolean value.

Be aware, after your ribbondiffxml has been imported and published your browser may keep the previous definition in its cache for some time, even after a page refresh.