Skip to main content
Post a question

Notifications

Community site session details

Community site session details

Session Id : OuJUxgmKwUkoxGVi5ZRdHi
Microsoft Dynamics CRM (Archived)

Retrieve all Display names of columns contained in a view by ViewId

Like (0) ShareShare
ReportReport
Posted on 7 Oct 2016 21:22:43 by

How can I retrieve all Display names of columns contained in a distinct view by ViewId, using C#.

The display names of the columns are not saved in the record itself of course, so from where can I get them using c#. I need the source.

Thanks.

*This post is locked for comments

  • Verified answer
    Tim Dutcher Profile Picture
    2,100 on 09 Oct 2016 at 00:25:10
    RE: Retrieve all Display names of columns contained in a view by ViewId

    With the SDK, you can query the savedquery entity by savedqueryid field (GUID). Be sure to return the field named "fetchxml" from the savedquery record.

    Once you have the view's fetch xml statement, you will need to parse the xml. You can identify the fields in the view by getting the "name" attribute's value for each "attribute" node. See the SDK for a sample of fetch xml. You'll see that the xml contains attribute nodes.

    Once you have the fields in the view, you can query CRM's metadata, using class RetrieveAttributeRequest, to get the display name of each of the fields.

  • Community Member Profile Picture
    on 08 Oct 2016 at 10:25:36
    RE: Retrieve all Display names of columns contained in a view by ViewId

    I want to retrieve the display names via c# code, I get the record, but the display names are not saved inside the record as they can be localized and differ by language...

    I found them in the database, but how to filter by view and get the right column order like in the view?

    I would prefer to go via SDK API...

    1. SELECT TOP 1000 [LocalizedLabelId]
    2. ,[LocalizedLabelRowId]
    3. ,[LanguageId]
    4. ,[ObjectId]
    5. ,[ObjectColumnName]
    6. ,[Label]
    7. ,[VersionNumber]
    8. ,[LabelTypeCode]
    9. ,[SolutionId]
    10. ,[SupportingSolutionId]
    11. ,[ComponentState]
    12. ,[OverwriteTime]
    13. ,[IsManaged]
    14. FROM [dbo].[LocalizedLabelAsIfPublishedView]
  • Community Member Profile Picture
    on 08 Oct 2016 at 10:22:27
    RE: Retrieve all Display names of columns contained in a view by ViewId

    on-prem using C# 

  • Suggested answer
    Nuno Profile Picture
    2,005 on 08 Oct 2016 at 09:11:56
    RE: Retrieve all Display names of columns contained in a view by ViewId

    Hi,

    Views are stored on a entity named 'savedquery'.

    msdn.microsoft.com/.../gg328457.aspx

    you may do a retrievemultiple for those records

    msdn.microsoft.com/.../gg328457.aspx

  • Suggested answer
    PS Profile Picture
    23,577 on 07 Oct 2016 at 22:57:46
    RE: Retrieve all Display names of columns contained in a view by ViewId

    Column names you can get just by exporting records from a view. ViewID you can get by pressing F11 when you are customizing the view.

    Let me know if you ar after something else

  • Tim Dutcher Profile Picture
    2,100 on 07 Oct 2016 at 22:20:23
    RE: Retrieve all Display names of columns contained in a view by ViewId

    Online or on-prem?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,337 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans
Loading complete