0

I have started working with the Ribbon Workbench for CRM Dynamics 365 and am having some problems. Specifically, I am need to hide a button if the form in question is Read Only and Active.

I've started by creating a DisplayRule that is assigned to the button in question. The DisplayRule consists of a FormStateRule with the following criteria

Default: False
State: ReadOnly
InvertResult: True

For some reason it isn't working. The button continues to display whether the Form is Read Only or not. Does anyone have any ideas as to how I can get it to work? A requirement this simple shouldn't be this difficult to do!

I should add that I can make the DisplayRule toggle the button in general based on other criteria, it's this exact set of circumstances that I can't figure out.

Cailean
  • 181
  • 2
  • 14
  • Possible duplicate of [How to hide a vanilla button according to form state](https://stackoverflow.com/questions/48141180/how-to-hide-a-vanilla-button-according-to-form-state) – Arun Vinoth-Precog Tech - MVP Jan 09 '18 at 21:08
  • No, this isn't a duplicate of that issue. I've already verified that the button has been set to been Customized. I can also get the Display Rule to toggle based on other settings, such as setting the State to Create. I just can't seem to figure out how to tell when the state of the Form is ReadOnly despite there being an option for ReadOnly, which apparently doesn't work as expected. – Cailean Jan 10 '18 at 00:27
  • Are you talking about CRM OOB read-only forms loaded for inactive records or disabling form controls some other means? Also checkout the InvertResult=false behavior. – Arun Vinoth-Precog Tech - MVP Jan 10 '18 at 02:51
  • No, this is a form that is in the Active state, but has also been set to ReadOnly in certain circumstances. – Cailean Jan 10 '18 at 13:18
  • You may be setting it in form load script after ribbon loaded, am I right? – Arun Vinoth-Precog Tech - MVP Jan 10 '18 at 13:19

2 Answers2

0

Probably you have to use the below snippet to refresh the Ribbon controls, once you set your form to ReadOnly mode.

Xrm.Page.ui.refreshRibbon();

This is needed as you are loading ReadOnly form on certain circumstances, where the record is still active.

0

It turns out the problem was that I was using a DisplayRule instead of an EnableRule. EnableRules provided me with a RecordPrivilegeRules. This provides the ability to determine the rights to the exact record in use as oppose to general access that you would get with a FormStateRule.

I'm a little mad at myself that it took so long to figure out something so simple, but hopefully this will help somebody else down the road.

Cailean
  • 181
  • 2
  • 14