In this webinar, our experts showcase a variety of demo use cases of how different components of the...
Many times we have come across the need to set privileges using Sitemap. The SiteMap defines the areas represented in the CRM client's main application Navigation Pane. We use the predefined privilege tags to achieve this.
Same feature is not available for entity Navigation Pane using isv.config. For implementing Role based security in Entity navigation pane, im presenting an example here.
In the example, we want to display Budget Spreadsheet link only if user has Read access to Budget Header entity.
We create a new Role, say 'Budget Read' and give it Read rights for Budget Header entity. Next, we assign this role to all users we want to give Read access on Budget Header entity.
Check the Id of Budget Spreadsheet in Navigation pane using IE Dev toolbar. On the formload, write the following JS:
var bsheet = document.getElementById('navIsvBudgetSpreadsheet');
bsheet.style.display='none';
(Save the above file as txt file to view code)
function UserHasRole(roleName)
{
//get Current User Roles, oXml is an object var oXml = GetCurrentUserRoles();
if(oXml != null)
{
//select the node text
var roles = oXml.selectNodes("//BusinessEntity/q1:name");
if(roles != null)
{
for( i = 0; i < roles.length; i++)
{
if(roles[i].text == roleName)
return true}
}
}
return false
}
if(UserHasRole('BudgetRead'))
{
var bsheet = document.getElementById('navIsvBudgetSpreadsheet');
bsheet.style.display=";
}
Thats it! You're ready to test your changes. Ofcourse there can be plenty of options you can exercise using similar techniques. Happy programming!