I'm trying to hide the ribbon button in an entity which will lies on the condition and depends on another entity.
Here is the scenario. There is an entity 'Account' it has ribbon button called 'Degrade'. In Account entity there is an Contact Lookup field which holds the contact records. Now in contact form there should be data in tab1, if there is no data/record present under the tab1 of contact record which is selected through lookup in Account then Degrate button should be hidden.
Here’s what you can do: Step 1: Create a JS web resource with code For example, I have created a function called “hideDegardeButton” which will check if the account entity contains contact lookup or not. If contact lookup is enabled, it will check the "fax" fields in the contact entity by calling the “checkFaxData” function, if not then it will return false. Note: “hideDegardeButton” function contains account form Control as parameter & “checkFaxData” function contains contact lookup id as parameter. If “fax” field in contact entity contains data then it will return true, if not then it will return false. Note: Based on the “return” values, I’m hiding the “Degrade” button in Account form.
Upload the JS web resource in a solution and Publish the Web resource.
Step 2: Prepare Ribbon Workbench In the ribbon work bench click the account entity and add the button that will enable the rule. Once selected, click on the Enable rule section and add a new rule or type of Custom Rule. Select the JS web resource and specify the function name. Add CRM parameter as Primary Control. Also ensure the following two steps before publishing the ribbon workbench
The Command must be attached to the button.
And the Enable Rule must be attached to Command itself.
Step 3: Publish and Test.
Know that the button is visible when Fax field contains values,
And that the button will not be visible when Fax field contains no values,
Hope this was helpful!
Thank you!
Was this reply helpful?YesNo
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.