Hide Show Ribbon button with Ribbon Workbench and JavaScript

Few simple steps to hide or show a ribbon button depending on the value of a field on a form.

Open your solution which contains entity you need to add button to using Workbench

Select Entity (in my case Task) and then expand Enable Rules

Right click on Enable Rules and Add New

Give it a name rki.task.EnableRule.EnableSetStart

Right click on rki.task.EnableRule.EnableSetStart and Add Rule

Select Custom JavaScript Rule

Set Default to False

Then give your JavaScript function name from your web resource – in my case following is the web resource I added and Function name is EnableSetStart

function EnableSetStart() { var _actualStart = Xrm.Page.getAttribute("actualstart").getValue(); if(_actualStart){ return false; } else { return true; } }

Select Web Resource against library

Then Go to Commands

Select your Button related Command

Click against Enable Rules and select your rki.task.EnableRule.EnableSetStart rule you created in steps above

Publish your changes and all good to go

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>