This is most common requirement that we need to show hide some fields based on the certain fields or user roles. It’s quite easy in Dynamics 365/CRM forms. We can utilize the Business Rules. But business rules will not work on the Dynamics portal form.
How to achieve this functionality in the Dynamics portal?
We can utilize the odata options to retrieve the records and find out the roles of the logged in user.
If we are using the Liquid templates/ Web templates to display the form in portals, we can do easily by utilizing the portal syntax.
Above syntax helps to set the logged-in user is Administrator or not in the is_admin variable. It will hold Boolean value.
If we are using the web templates, we can directly utilize this variable in the template.
If we are using Entity Forms, we will not have access to the web template syntax in Entity form based java-script. But we planned to have one html input element in the web template and store the above results and kept it hidden.
On load of the page, the value will be manipulated and we can access that value using java-script.
//do something for admin user
//do something for non-admin user
we can utilize the web template syntax and form java-script to play around on this.Similar logic can be applied for different scenarios.
Hope it makes sense. Please do let me know if you need any help on this. Happy to assist..