Enable/Disable a ribbon button dynamically based on a form value

Enable/Disable a ribbon button dynamically based on a form value

Recently , we had a requirement , that the custom button must be visible  based on the  form value. we can achieve this requirement in two ways

  1. Value Rule  and 2. Custom Code Rule.

Value Rule- 

Based on one and only one value, the button will be visible or disabled. if u hv to hide button based on 2 or more form field values go with ” Custom Rule ” or ” OR Rule between value rule  “.

Go to- Command- Display Rule- Value Rule

Manually enter filed name and value.. If value equal to that filed then only the button will be visibled otherwise button will be on hidden mode.


Custom Rule 

Go to- Enable rules- Custom Rule.

It will ask the function name and web resource name. Before that add the web resource in Ur solution, so that when u click on search button it will display and select that web resource. give Exact function name .


web resource – JavaScript code as follows:-

//button will be visible when name exactly equals to "gb".Otherwise button Goes to hide
function hide(){
 var name = Xrm.Page.getAttribute("name").getValue();
 return true;
 return false;

Add the above Enable rule to command and attach the command to button.

Thats it.

Crming- Enjoy 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s