Hi,
I want to show only one view to a user and want to hide all other views from user. At present i have 10-14 views under work order entity.
Do anyone has any idea on how to do this on new UI, we did achieved it on old classic web,but someone in my last post said for new UI there is different way
Here is the link for my old post
community.dynamics.com/.../need-to-hide-all-views-for-the-entity-except-one-for-a-particular-user
Kokulan would you please help me to find a way to do the same on new UI. If anyone else has any ideas, please help.
Thank you
*This post is locked for comments
Hi @kartik
Actually on new UCI ialso did not implemented this thing. Lets see what LA has to say
So if there are multiple customers and I want them to see their own data, I create separate business units and separate security roles.
There is one security role, lets say Field service - Resource, not different resource should have access to their own data.
And as per app basis, do i create different apps for different users?
Actually plugin is not being fired on retrievemultiple savedquery in UCI. it’s not like code is not working.
Actually, what we want to do is, Consider there are 3 customers and Each one should view their View, they all have same sort of security roles and everything is same, all we want is that they just see the view that shows data of their company. Will this be possible?
[/quote]Note, hiding a view, does not mean that the user cannot access the data (e.g. if the user has access to Advanced Find or puts an oData query in the browser they can work around the View).
Usually we wouldn't let an external user directly access CRM, but would establish a Portal for them to access the relevant data from.
If the user is more of an internal user, then I would establish the relevant Business Units, Security Roles and record ownership to achieve the segmentation/separation. This then lets the CRM security model manage record access (in this case the views they have access to becomes less relevant as they only have access to the records they are meant to see as the Security Model is controlling access to the underlying data).
Actually, what we want to do is, Consider there are 3 customers and Each one should view their View, they all have same sort of security roles and everything is same, all we want is that they just see the view that shows data of their company. Will this be possible?
This may not work for your particular situation, however in the new UI in the Model Driven App you can select what views to include in the App on a per Entity basis. e.g. you could have 1 app that has 7 views and another App that has 1 view on the same entity (specific apps can have Security roles assigned to control access to that App).
Hi Kartik,
i had to stop it from implementing because of some reason.
From the above code use this else section and paste the view visible code
else if (context.InputParameters["Query"] is FetchExpression)
{
var objFetchExpression = context.InputParameters["Query"] as FetchExpression;
// ToDo : Add your code here to work with UCI
}
you can check this code, i used similar like this one for my old classic one, to make one view visible as per user and it was a success.
community.dynamics.com/.../show-hide-views-based-on-user-security-role
Hi Ravi,
I am having the same issue. did you find any alternative or solution for the same?
Hi
Your the above code will only work for Classic UI as you are not converting the query parameter to FetchExpression.
Please see below for the main blocks you could have to support both UIs in retrieve multiple plugin
if (lcontext.InputParameters["Query"] is QueryExpression)
{
var objQueryExpression = context.InputParameters["Query"] as QueryExpression;
// ToDo: Add your code here for it to work for Classic UI
}
else if (context.InputParameters["Query"] is FetchExpression)
{
var objFetchExpression = context.InputParameters["Query"] as FetchExpression;
// ToDo : Add your code here to work with UCI
}
Hi There,
We did try Fetchxml directly for query. Below is our code
if (context.InputParameters.Contains("Query") && context.InputParameters["Query"] is QueryExpression)
{
trace.Trace("Plugin Started");
QueryExpression qe = (QueryExpression)context.InputParameters["Query"];
if (qe.EntityName == "savedquery")
{
trace.Trace("savedquery");
string roleName = "Field Service - PSE User";
bool userRoleFound = VerifyIfUserHasRole(roleName, context.UserId, service);
if (userRoleFound)
{
string oppFetchXmlPSEView = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='savedquery'>
<attribute name='name'/>
<attribute name='description'/>
<attribute name='savedqueryid'/>
<order attribute='name' descending='false'/>
<filter type='and'>
<filter type='or'>
<condition attribute='name' operator='eq' value='PSE Active Work Orders'/>
<condition attribute='name' operator='eq' value='PSE Active Bookable Resource Bookings'/>
</filter>
</filter>
</entity>
</fetch>";
//EntityCollection resultOppPSEView = service.RetrieveMultiple(new FetchExpression(oppFetchXmlPSEView));
}
}
public bool VerifyIfUserHasRole(string roleName, Guid userId, IOrganizationService crmService)
{
bool userRoleFound = false;
string fetchXmlString = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='role'>
<attribute name='name' />
<attribute name='roleid' />
<link-entity name='systemuserroles' from='roleid' to='roleid' visible='false' intersect='true'>
<link-entity name='systemuser' from='systemuserid' to='systemuserid' alias='ab'>
<filter type='and'>
<condition attribute='systemuserid' operator='eq' value='" + userId + @"' />
</filter>
</link-entity>
</link-entity>
</entity>
</fetch>";
EntityCollection entColl = crmService.RetrieveMultiple(new FetchExpression(fetchXmlString));
if (entColl != null && entColl.Entities != null && entColl.Entities.Count > 0)
{
int count = entColl.Entities.Select(x => x.GetAttributeValue<string>("name")).Where(y => y.ToString().ToUpper().Trim() == roleName.ToUpper()).Count();
userRoleFound = count > 0;
}
return userRoleFound;
}
}
But still facing an issue.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156