2

I have to hide a ribbon button when the owner of the record isn't the current user.

I'm using Visual Ribbon Editor for CRM 2011 however I didn't find out the solution yet. I tried to use Field rule ValueRule but it just allows me to put a bool value (1 or 0).

Can anyone please tell me how can I do that?

Thank you in advance!

Guido Preite
  • 14,905
  • 4
  • 36
  • 65
Bruno Willian
  • 160
  • 2
  • 5
  • 18
  • 2
    try with Ribbon Workbench http://www.develop1.net/public/page/Ribbon-Workbench-for-Dynamics-CRM-2011.aspx I don't remember if is possible to do without a javascript rule, if I have time I will test and write an answer – Guido Preite Aug 26 '13 at 21:36
  • possible duplicate of [crm 2011 how to hide/show the ribbon button with javascript](http://stackoverflow.com/questions/14585141/crm-2011-how-to-hide-show-the-ribbon-button-with-javascript) – Daryl Aug 27 '13 at 00:38

2 Answers2

3

Add a Enable Rule like this:

<EnableRules>
    <EnableRule Id="YourEntity.Form.XXX.MainTab.XXXXXXXXXX.CustomRule" />
</EnableRules>

Rule Definitions as below:

<RuleDefinitions>
    <TabDisplayRules />
        <DisplayRules />
        <EnableRules>
            <EnableRule Id="Email.Form.email.MainTab.XXXXXXXXXX.CustomRule">
                <CustomRule FunctionName="DisableButton" Library="$webresource:new_/js/xxx.js" InvertResult="true" />
            </EnableRule>
        </EnableRules>
</RuleDefinitions>

Write a JavaScript function DisableButton and to return true or false based on your condition. Reference the js webresource in CustomRule Library.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Scorpion
  • 4,495
  • 7
  • 39
  • 60
  • @BrunoWillian your welcome, Please mark as a answer if it helped you. Cheers – Scorpion Aug 28 '13 at 15:06
  • Why does that code don't work with ? like this. – Bruno Willian Aug 29 '13 at 21:06
  • @BrunoWillian have you tried to use RibbonEditor? You can easily generate the working xml using RibbonEditor. – Scorpion Aug 30 '13 at 08:34
  • Yes I did but its dosn't able me to insert custom rule on ribbon button. This way you gave me totally works with Enable Rule. But what I wanted is put a custom rule in Display Button not in Enable button. I've searched for that but all examples and posts I've found out is about Enable. Sadly it's looking like that's not possible to put a Custom Rule in Display Rule of a button. – Bruno Willian Aug 30 '13 at 13:05
2

Value Rules cannot be used with Hide Actions - so you'll need to use a Custom JavaScript Rule with an Enable rule to enable/disable the button rather than hide it.

Scott Durow
  • 557
  • 4
  • 10