Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ribbon button value rule depending on statecode value

I added a new custom button to quote form ribbon. This button should only appear, if the statecode is active (Value: 1).

I created following CommandDefinition:

<CommandDefinition Id="mySolution.quote.Form.MyButton.Command">
    <EnableRules />
    <DisplayRules>
        <DisplayRule Id="mySolution.QuoteIsActive" />
    </DisplayRules>
    <Actions>
        <JavaScriptFunction FunctionName="myFunction" Library="$webresource:new_myLibrary" />
    </Actions>
</CommandDefinition>

And following DisplayRule:

<DisplayRule Id="mySolution.QuoteIsActive">
    <ValueRule Field="statecode" Value="1" Default="true" />
</DisplayRule>

But if I use this DisplayRule my button never appears. If I remove the rule from CommandDefinition the button is always visible.

I also tried to use 'Active' as value (as shown at the bottom of this post, with the same result.

What is the trick to define a rule depending on statecode? Or did I miss something?

like image 606
Marvin Avatar asked Sep 16 '26 15:09

Marvin


2 Answers

Try using Status text values ("Open", "Draft", "Active", ect.) instead of number values. I have a similar case with Status Reasons. Hope it will help!

like image 160
Khoait Avatar answered Sep 20 '26 04:09

Khoait


I couldn't find anything to verify this, but display rules seem to have issues in the command bar. I had better luck using enable rules, and those actually act like you would expect display rules to act in the command bar. In other words, if a button in the command bar is disabled then it's not displayed. You can read about it in the MSDN documentation.

like image 42
fenix.shadow Avatar answered Sep 20 '26 03:09

fenix.shadow