0

I want to find the name and columns set in all Views of entity of dynamic crm with the use of javascript.

enter image description here

This names for entity display in above image and columns which are set in view.

1 Answer 1

2

"Saved Query" is the entity that holds all the data related to system views. However getting the columns will require some parsing as the "Grid" is stored as an xml in the "LayoutXml" attribute of the entity.

For e.g. to fetch views on "contact" entity:

OData:

GET [Organization URI]/api/data/v8.0/savedqueries?$select=name,layoutxml&$filter=returnedtypecode eq 'contact'

FetchXml (Use SDK.js or XrmServiceToolkit):

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="savedquery">
    <attribute name="name" />
    <attribute name="layoutxml" />
      <filter type="and">
        <condition operator="eq" attribute="returnedtypecode" value="2"/>
      </filter>
  </entity>
</fetch>

Sample "LayoutXml" for "Active Contacts" view:

<grid name=\"resultset\" object=\"2\" jump=\"fullname\" select=\"1\" icon=\"1\" preview=\"1\"><row name=\"result\" id=\"contactid\"><cell name=\"fullname\" width=\"200\" /><cell name=\"telephone1\" width=\"100\" /><cell name=\"mobilephone\" width=\"100\" /><cell name=\"telephone2\" width=\"100\" /><cell name=\"fax\" width=\"100\" /><cell name=\"emailaddress1\" width=\"150\" /><cell name=\"address1_line1\" width=\"100\" /><cell name=\"address1_line2\" width=\"100\" /><cell name=\"address1_city\" width=\"100\" /><cell name=\"address1_postalcode\" width=\"100\" /><cell name=\"parentcustomerid\" width=\"150\" /></row></grid>

Parsing the xml for all cell elements you would get the view columns (e.g.):

<cell name=\"fullname\" width=\"200\" />
<cell name=\"telephone1\" width=\"100\" />
Sign up to request clarification or add additional context in comments.

2 Comments

Thanx for the reply. I get my answer with OData query given by you with adding '&' before $filter.
@chhaya_patel I added the filter after the fact, edited the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.