How to Hide the Share Button in a Model-Driven App in Dynamics 365
In a Model-Driven App built on Dynamics 365 or Power Apps, customization is key to tailoring the user experience to your organization's specific needs. However, some customization tasks, such as hiding the Share button, can be more challenging than others. However, in some scenarios, you may want to hide this button to restrict record sharing capabilities. In this blog post, we'll explore different methods for hiding the Share button in a Model-Driven App and provide step-by-step instructions for each approach.
Method 1: Ribbon Workbench Alternative
Traditionally, Ribbon Workbench has been the go-to tool for customizing the ribbon (command bar) in Dynamics 365 and Power Apps. However, it may not always provide a direct option to hide the Share button, especially if the button is not customizable. In such cases, you may need to explore alternative solutions.
Method 2: Security Roles Configuration
Another approach to hide the Share button is by configuring security roles. However, this method may not always work as expected. In some cases, the Share button may be visible even if users do not have the necessary privileges to share records.
Method 3: Manipulating Solution XML
One of the more advanced methods for customizing a Model-Driven App is to manipulate the underlying XML of the solution. While this approach requires a deeper understanding of the solution structure and customization concepts.?
Step-by-Step Guide:
Now, let's walk through the steps for hiding the Share button in a Model-Driven App using the XML manipulation method:?
1. Export Solution: Start by exporting the solution containing the Model-Driven App you want to customize.p?
2. Extract Solution ZIP: Extract the exported solution ZIP file to access the solution components, including the customization.xml file.?
3. Locate RibbonDiffXML: Within the customization.xml file, locate the RibbonDiffXML section, which defines the ribbon customization for the app.?
4. Find Share Button: Search for the Share button definition within the RibbonDiffXML section. This may require some familiarity with XML structure and ribbon customization schema.?
5. Remove Share Button: Once you've identified the Share button definition, remove or comment out the corresponding XML elements to hide the button.
6. Save Changes: Save the modified customization.xml file.?
7. Import Solution: Import the modified solution back into your Dynamics 365 environment.?
8. Publish Changes: After importing the solution, publish the customizations to apply the changes to the Model-Driven App.
领英推荐
Method 4: JavaScript Approach
Customizing the user interface in with JavaScript is a common practice. By utilizing developer tools, we can retrieve the id of the Share button, typically labeled as "collaborationShareButton". However, this id often varies with numeric postfixes up to 100. Hence, we must develop a dynamic function. Below is the function to be invoked upon form load for the designated entity to hide the Share button.
function hideShareButtononForm() {
for (var i = 0; i < 100; i++) {
if (!!window.top.document.getElementById("collaborationShareButton_" + i)) {
window.top.document.getElementById("collaborationShareButton_" + i).style.display = 'none';
return;
}
}
}
?Conclusion:
While hiding the Share button in a Model-Driven App may require advanced customization techniques, such as manipulating solution XML, it's achievable with the right approach and understanding of the customization options available. By following the step-by-step guide outlined in this blog post, you can successfully customize your Model-Driven App to meet your organization's specific requirements.
I hope you found this article useful and informative. I would love to hear your feedback, thoughts, or suggestions. You can contact me at [email protected] or send me a message on LinkedIn Komal Ridda Malik.
Happy reading!