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)

How to retrieve the Shared Views of a SystemUser?

(0) ShareShare
ReportReport
Posted on by

Hello,

im trying give the user of my app a dropdown with all their views as well as their shared views from other users.

Now i know how to get a users personal views and it works fine but when i get to the part where i have to get the Shared Views i seem to not be able to find a way.

So first of all here the Code i have right now:

        public List<Views> GetUserOwnedAccountViews(Guid sysuserID, bool includeFetchXML)
        {
            List<Views> allViews = new List<Views>();

            FilterExpression filter = new FilterExpression();
            filter = new FilterExpression();
            filter.FilterOperator = LogicalOperator.And;
            ConditionExpression cex = new ConditionExpression("returnedtypecode", ConditionOperator.Equal, 10092);
            filter.Conditions.Add(cex);
            ConditionExpression cex2 = new ConditionExpression("ownerid", ConditionOperator.Equal, sysuserID);
            filter.Conditions.Add(cex2);

            QueryExpression query = new QueryExpression()
            {
                Distinct = false,
                EntityName = UserQuery.EntityLogicalName,
                ColumnSet = new ColumnSet("name", "userqueryid", "description", "fetchxml", "returnedtypecode", "ownerid"),
                Criteria = filter
            };

            EntityCollection result = _service.RetrieveMultiple(query);
            foreach (Entity entity in result.Entities)
            {
                UserQuery sq = entity.ToEntity<UserQuery>();

                Views vw = new Views();
                vw.Id = sq.Id.ToString();
                vw.Name = sq.Name;
                vw.Description = sq.Description;
                if (includeFetchXML)
                {
                    vw.Query = sq.FetchXml;
                }
                allViews.Add(vw);
            }       

            return allViews;
        }

Now how could i get the SharedViews of the user?

I read a few Posts and found out that apparantly "Shared Records/Views" are saved in something called "PrincipalObejctAccess" but i don't know how to use that.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Radu Chiribelea Profile Picture
    6,667 on at

    Hi Maximilian.

    I don't know if you can do a join with the PrincipalObjectAccess table. But you can try to iterate through each user view and use this request docs.microsoft.com/.../gg308215(v%3Dcrm.8)

    Hope this helps,

    Radu

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 March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
JS-09031509-0 Profile Picture

JS-09031509-0 3

#2
AS-17030037-0 Profile Picture

AS-17030037-0 2

#2
Mark Eckert Profile Picture

Mark Eckert 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans