Search code examples
dynamics-crm-2011dynamics-crmcrmribbon

Hide Ribbon Button Crm 2011


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!


Solution

  • 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.