Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Obtaining schema of View to mirror it inside mobile app

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

I am looking for a help regarding obtaining schema of view through WebApi. What I need is how the view looks, what are the columns for each entity list etc.

For example this one:

pastedimage1605865747244v1.png

What is the endpoint through WebApi to get list of columns visible to the user in Leads ?

Looking for a quick help, thanks in advance.

  • Suggested answer
    RE: Obtaining schema of View to mirror it inside mobile app

    Hey, I hope you managed to find the relevant endpoints. In case you still have doubts, here is a quick answer to all your three queries. 

    1) To get a list of Views for a given entity you can use the /api/data/v9.1/savedqueries table savedquery EntityType (Microsoft.Dynamics.CRM) | Microsoft Docs. If you are only interested in retrieving the views for a specific entity you can filter by the returnedtypecode. Below is an example of a query to retrieve all the names of views for the account entity. 

    /api/data/v9.1/savedqueries?$filter=returnedtypecode%20eq%20%27account%27&$select=name

    2) To get the Form layout for a given Form (assuming you know the ID) you can use the systemforms table /api/data/v9.1/systemforms systemform EntityType (Microsoft.Dynamics.CRM) | Microsoft Docs. Here is an example to get just the formxml of a system form with ID 8448b78f-8f42-454e-8e2a-f8196b0419af

    /api/data/v9.1/systemforms(8448b78f-8f42-454e-8e2a-f8196b0419af)?$select=formxml

    3) In order to view the xml of the sitemap of a model driven app you can refer to the api/data/v9.1/appmodules table https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/appmodule?view=dynamics-ce-odata-9. Here is an example of how to get just the configxml for the Customer Service Hub app. 

    api/data/v9.1/appmodules?$filter=name%20eq%20%27Customer%20Service%20Hub%27&$select=configxml

    In general I would also strongly suggest you take a look at this whole document https://docs.microsoft.com/en-us/dynamics365/customer-engagement/web-api/about?view=dynamics-ce-odata-9. In the EntityType section you will find a list of all the tables you can access directly. You can also inspect them more "manually" simply by visiting the /api/data/v9.1/ address. That way you can also see all the tables that are explicitly available to you. Hope this helps and wish you good luck :) 

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Obtaining schema of View to mirror it inside mobile app

    Hey Tomasz,

    Thank you very much for the answer, it helps.

    I have 3 more questions:

    1) How to get list of views and their ids (All Leads, My Open Leads, etc...) for given entity type(?) - Lead, Contact, Account?

    2) How to get same layoutxml (or layoutjson) as we got from savedqueries in your response, but for Entity:

    Zrzut-ekranu-2020_2D00_11_2D00_20-o-17.39.37.png

    3) How to get layoutxml for left navigation bar:

    pastedimage1605890535773v1.png

    I hope you have answers to these questions. Sorry, if it looks like I have not read documentation, but I really couldn't find it for quite a long time.

    Best regards,

    Artur

  • RE: Obtaining schema of View to mirror it inside mobile app

    Czesc Artur!

    If I am understanding you correctly you should be able to easily get the fetchxml and layoutxml of the query that is performed by the view using a simple query to the web api like this https://<orgURL>/api/data/v9.1/savedqueries(<ViewID>). In the results you will find all the details and metadata of the View. If you are interested in the layoutxml specifically just to see what are the columns displayed you can use this query https://<orgURL>/api/data/v9.1/savedqueries(<ViewID>)?$select=layoutxml which will give you the following results for this example View
    pastedimage1605885780507v1.png

    pastedimage1605885842007v2.png

    (The company name is hidden and so not displayed in the UI). I also highlighted how you can get the ID of the View from the URL when opening the view in the application. But I think the essence of the answer is that the Views are stored in the savedqueries table in the Web API (savedquery EntityType (Microsoft.Dynamics.CRM) | Microsoft Docs). If you are interested in more robust queries and filtering using the web api I would also suggest you take a look here Query Data using the Web API (Microsoft Dataverse) - Power Apps | Microsoft Docs

    Hope this helps! 

    PS 

    If you are just interested in getting ALL the possible fields (columns) for the entity (in this case Lead) you need to query the Attributes table. Here is an example https://<orgURL>/api/data/v9.0/EntityDefinitions(LogicalName='lead')?$select=LogicalName&$expand=Attributes($select=LogicalName,DisplayName) which will give you something like the below (just displaying LogicalNames in my example below). 

    pastedimage1605886553399v1.png

    For more details on querying metadata using the Web API (and its limitations) please take a look here https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/query-metadata-web-api 

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans