web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Need to hide all views for the entity except one for a particular user in new UI

(0) ShareShare
ReportReport
Posted on by 836

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

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    If you have achieved this by writing plugin then this should work in new UI as well. This is because plugins works server side the new ui has the client side changes only.

    Did you actualy check if this is not worming in new ui or you are assuming that it will not work?

    If haven't check, please check and if this is not working then see if you are getting any error in the plugin.

    Hope this helps.

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    As I mentioned in the previous post, Retrieve Multiple plugins on UCI use FetchExpression, not QueryExpression.

    Your code converts the query parameter to QueryExpression and the result will be null for UCI, meaning your plugin will fail for UCI.

    If you want your plugin to work for UCI, you will have to convert the query parameter to FetchExpression.

    Please follow the links below and see if you can get this working.

    crmtipoftheday.com/.../

    docs.microsoft.com/.../convert-queries-fetch-queryexpression

    I would recommend you update your plugin to work with both UCI and Classic UI.

    If you have issues getting this working for UCI, please let us know, I should be able to give you sample code that should cover both UCI and Classic UI retrieve multiple plugins

  • Ravi Fulani Profile Picture
    836 on at

    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.

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at

    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

                       }

  • Kartik MS CRM Profile Picture
    40 on at

    Hi Ravi,

    I am having the same issue. did you find any alternative or solution for the same?

  • Ravi Fulani Profile Picture
    836 on at

    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

  • Fubar Profile Picture
    2,761 on at

    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).

  • Ravi Fulani Profile Picture
    836 on at

    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?

  • Fubar Profile Picture
    2,761 on at
    [quote user="Ravi Fulani"]

    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).

  • Kartik MS CRM Profile Picture
    40 on at

    Actually plugin is not being fired on retrievemultiple savedquery in UCI. it’s not like code is not working.

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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans