How to find name and information about views of entity using javascript in dynamics crm

大兔子大兔子 提交于 2019-12-14 03:18:34

问题


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:


"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\" />


来源:https://stackoverflow.com/questions/38990647/how-to-find-name-and-information-about-views-of-entity-using-javascript-in-dynam

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!