Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

Posted on by 375

I have figured out how to conditionally show/hide buttons such as Activate, Deactivate, etc based off of security role.  However, I cannot seem to be able to do so with the Word and Excel Templates.  You may be able to if you can apply an action.  Has anyone done this or can offer a solution?

RWB_2D00_WordExcelTemplateAction.png

*This post is locked for comments

  • RugerSR762 Profile Picture
    RugerSR762 375 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    Nevermind.  Apparently, this is native functionality.  The top ribbon does not show on associated view.  Sorry!

  • RugerSR762 Profile Picture
    RugerSR762 375 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    Hello, I am back!  Well, the recommendations to hide/show accordingly did work... however, now we are noticing that on related/associated records the ribbon is completely gone!  From my research it appears that if there is an issue with the ribbon, it will just fail to load.  Has anyone else experienced this with Ribbon workbench?  

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    Hi Ruger,

    Go to the display rule Mscrm.TemplatesFCBEnabled and set the IsCore property to True.

    Now you will be able to publish the changes.

    See: https://ribbonworkbench.uservoice.com/forums/155731-general/suggestions/12248079-visibility-rules-incorrectly-classified-as-empty

    Hope this helps.

  • RugerSR762 Profile Picture
    RugerSR762 375 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    I did try that. Here is the error on publish:

    RWB_5F00_WordTe_2C00_pError.PNG

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    Hi Ruger,

    You just need to add the Enable Rule (Custom Rule) as shown below. No need of adding actions to the button. 

    4810.Capture1.PNG

    4810.Capture1.PNG

    Hope this helps.

  • RugerSR762 Profile Picture
    RugerSR762 375 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    Thanks for your replies!  I did however already have in place the JS to setup the Enable Rule.  The issue I am encountering however is when attempting to set a conditional show/hide on the Word and Excel Templates button.  It requires an action which is blank.  Do you know what action I need to call or does this require a custom action?

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    This should be possible through editing the ribbon on your required entities. The best tool for doing this is Scott Durow's Ribbon Workbench.

    Refer this how to do using security privileges,

    ribbonworkbench.uservoice.com/.../76681-hide-a-standard-out-of-the-box-button-based-on-a

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Conditionally hide Word/Excel Template buttons using Ribbon Workbench (or another solution)

    Hi Ruger,

    You can add Custom Javascript Enable Rule in Ribbon workbench by adding a JS web resource in CRM as follows:

    function getUserRoles() {
        var roles = Xrm.Page.context.getUserRoles();
        for (var i = 0; i < roles.length; i++) {
            var roleID = roles[i];
            var RoleName = getRoleName(roleID);
            if (RoleName == 'Security Role Name') {
                return false;
                break;
            }
            else {
                return true;
            }
        }
    }
    function getRoleName(roleID) {
        var clientURL = Xrm.Page.context.getClientUrl();
        var req = new XMLHttpRequest();
        var query = "/api/data/v9.0/roles/?$top=1&$select=name&$filter=roleid eq " + roleID;
        req.open("GET", encodeURI(clientURL + query), true);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.onreadystatechange = function () {
            if (this.readyState == 4) {
                req.onreadystatechange = null;
                if (this.status == 200) {
                    var data = JSON.parse(this.response);
                    if (data && data.value) {
                        for (var indx = 0; indx < data.value.length; indx++) {
                            var roleName = data.value[indx].name;
                            return roleName;
                        }
                    }
                }
                else {
                    var error = JSON.parse(this.response).error;
                    alert("Error retrieving Roles :" + error.message);
                }
            }
        };
        req.send(null);
    }

    Replace the 'Security Role Name' with the required security role name for whom you need to hide/disable the button.

    Now add a enable rule for both the ribbon buttons (Word and Excel) as shown in the link below.

    https://garethtuckercrm.com/2013/11/25/dynamically-disable-ribbon-buttons-in-dynamics-crm/

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans