Skip to content Skip to sidebar Skip to footer

How To Find Name And Information About Views Of Entity Using Javascript In Dynamics Crm

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

Solution 1:

"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):

<fetchversion="1.0"output-format="xml-platform"mapping="logical"distinct="false"><entityname="savedquery"><attributename="name" /><attributename="layoutxml" /><filtertype="and"><conditionoperator="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\" />

Post a Comment for "How To Find Name And Information About Views Of Entity Using Javascript In Dynamics Crm"