Dynamics 365 custom lookUp Find view

API methods use Microsoft's own will find lookup field view can be filtered,

Xrm.Page.getControl(arg).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault)

arg: need to filter the lookup field

viewId: Custom Find view GUID (write a random GUID on it)

entityName: Entity Name

viewDisplayName: View Name

fetchXml: fetchXml inquiry

layoutXml: XML-defined layout view

isDefault: Should the view is the default view

Note: This method can not be used for "person in charge" Find

Examples are as follows:

const arg = "new_user_id"; //lookup字段
const viewId = "{33DC9B55-CC17-3F12-ASD6-F7533CC8B1B4}"; //视图ID
const entityName = "new_user"; //实体
const viewDisplayName = "自定义查找"; //视图名称
const isDefault = true //视图默认方式
const name = "上海"; //城市查询条件

//构造的FetchXML
const fetchXml = `<fetch version='1.0' output-format='xml-platform' mapping='logical'><entity name='new_user'><attribute name='new_name'/><attribute name='new_userid'/><link-entity name='new_city' from='new_user_id' to='new_userid'><filter type='and'><condition attribute='new_name' operator='eq' value='${name}'></condition></filter></link-entity></entity ></fetch >`

//构造的LayoutXML(视图布局)
const layoutXml = `<grid name='resultset' object='1' jump='${entityName}id' select='1' icon='1' preview='1'><row name='result' id='${entityName}id'><cell name='new_name' width='100'/></row></grid>`;

//构造lookup自定义查找视图
Xrm.Page.getControl(arg).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, isDefault)

 

Published 21 original articles · won praise 0 · Views 602

Guess you like

Origin blog.csdn.net/Stodger0216/article/details/103694385