web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Enable Rule for "Print Quote for Customer" button in Quote entity

(0) ShareShare
ReportReport
Posted on by

Hi,

I have created a Custom button that behaves likes Standard "Print quote for customer" button using Ribbon workbench.

I want this button to be enabled only for users with "System administrator" or "system customizer" role.

1. Can i create an enable rule for command "Mscrm.Form.quote.PrintQuote" ? 

2. Can i use "Custom Javascript function" step in enable rule for the function below ?

function HidePrintQuoteforCustomerButton(){
if(UserHasRole("System Administrator")||UserHasRole("Delegate"))
return false;
else
return true;
}

When i am doing this, the form ribbon stops working.

Please guide, how to enable security based display on this button?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Hosk Profile Picture
    on at

    you need to see if your Javascript is being run.  

    is the javascript file you are calling loaded?

    does your UserHasRole function work? is it being called? is it erroring?

    press F12 and put a breakpoint on the your function.

    you could simplify your javascript just to test it's working.

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Tanu,

    Yes, it is possible.

    This is what we have done before.

    So, you need to customize the command and add new Display or Enable Rule.

    enableruleribbonstandard3.png

    And then you add the enable rule that you've created before.

    And this is the result, no more Print Quote..

    I think the problem is the UserHasRole function on your code.

    if(UserHasRole("System Administrator")||UserHasRole("Delegate"))

    Is that you have in the same library (same .js) or use a referenced library?

    To make it easier, you better place in the same .js file

    Hope this helps!

    Thanks.

  • Community Member Profile Picture
    on at

    Hi Ben,

    I pressed F12, On load of quote entity the js is not loading as the applied debugger is not hitting.

    How to enable this js to work ?

  • Community Member Profile Picture
    on at

    Hi Alieen,

    Thanks for the reply.

    I tried adding a value display rule for this button. It is working.

    But when i add custom javascript enable rule, then it is not working.

    In my solution, i have quote entity, js and images.

    I have only one function in js and i am calling that function.

    Seems like js is not loading.

    Please guide further.

    I want to show the button only for Sys adm and sys customizer.

    If you can help with js / what can be possible errors with my js?

    Thanks.

  • Community Member Profile Picture
    on at

    Attachments :

  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Tanu,

    This is good example, very useful

    http://www.develop1.net/public/post/Dynamically-ShowHide-a-standard-ribbon-button-based-on-a-form-value.aspx

    You only have 1 function in js but under your HidePrintQuoteforCustomerButton you call another fuction UserHasRole which doesnt exist in the js file.

    So, it will give error.

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Alieen,

    I achieved the functionality through custom js rule on enable rule.

    BUT....

    I want to apply display rule for button, NOT ENABLE RULE.

    Process included :

    1. Create js. Call js function on Form Load. The function checks if user is sys adm, then it fills two option field with Yes, else No. The field name is "abc".

    2. Through ribbon workbench, I created display rule on this field, abc.

    Output :

    On form load, the field is populated with correct value, but the button is not showing.

    Is it that the ribbon loads previous to form load / why is it not showing. ?

    Please guide.

  • Suggested answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi Tanu,

    Basically, CRM will render ribbon workbench and form on load in two different method onLoad function.

    So, rather than you put in the formOnLoad, better you put your .js function into to the display rule in CRM Ribbon.

    If you use the formOnLoad function, the ribbon was rendered using the display rule or enable rule you defined in the ribbon rule using Ribbon Workbench, after the form onLoad and your function runs correctly, but it will not refresh the ribbon.

    If you still want to use it, suggestion, you add this function:

    function refreshRibbonOnChange()

    {

       Xrm.Page.ui.refreshRibbon();

    }

    Source from the author:

    www.develop1.net/.../Dynamically-ShowHide-a-standard-ribbon-button-based-on-a-form-value.aspx

    If only checking the user is admin or not (not contextual and dynamically based on the form value that can change every time), better you use display rule.

    See this:

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

    You can use your javascript by return true or false.

    Hope this helps!

    Thanks.

  • Community Member Profile Picture
    on at

    Hi,

    I'm a newbie on CRM and I would like to ask how did you create a custom button that behaves like the standard "Print Quote For Customer" button using Ribbon Workbench? 

    Hoping for your response. Thank you so much!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans