3

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?

1

5 Answers 5

3

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!

0
1

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.

0

I think your problem here is that your EnableRules is empty. However, are you doing that modifications by hand? If so, use CRM 2011 Visual Ribbon Editor, this tool will do almost all job for you.

2
  • I this this is not the problem. If I remove the display rule the button appears. And I am doing that modification by hand. We had bad experience with using ribbon editors.
    – Marvin
    May 19, 2014 at 14:55
  • If u have a Test organization I would recommend you to do that with the tool and see how the Fetch.xml will look like.
    – Jorge
    May 19, 2014 at 15:15
0

I think that your problem is that Statecode should be 0, not 1. Do a sql query on statecode and statecodename (use FilteredView).

0

Just add simple .js script for updating ribbon. Ribbon updates only on page load. Thats why your button became always unvisible. Here is code sample:

function refreshRibbonOnChange()
{
   Xrm.Page.ui.refreshRibbon();
}

Then add web resource and attach it to button click. Simple!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.