This is a recurring functionality that often a developer has to write and i will put in here as a reminder, change the view of a lookup field to meet some customer requirements, adding/removing columns or even add filters to a lookup field. Don’t remember by heart, but from one version of crm, porbably 3.0 to 4.0 or 4.0 to 2011, that changed. I took this from the Microsoft Developer Network webbsite.
var viewId = "{C7034F4F-6F92-4DD7-BD9D-9B9C1E996380}";
var viewDisplayName = "SDK Sample View";
var fetchXml = "
"output-format='xml-platform' " +
"mapping='logical'>" +
"" +
"" +
"" +
"
"descending='false' />" +
"" +
"
"operator='eq-userid' />" +
"
"operator='eq' " +
"value='0' />" +
"
" +
"" +
"" +
"" +
"
"alias='accountprimarycontactidcontactcontactid' " +
"name='contact' " +
"from='contactid' " +
"to='primarycontactid' " +
"link-type='outer' " +
"visible='false'>" +
"" +
"" +
"" +
"";
var layoutXml = "
"object='1' " +
"jump='name' " +
"select='1' " +
"icon='1' " +
"preview='1'>" +
"
"id='accountid'>" +
"
"width='300' />" +
"
"width='100' />" +
"
"width='100' />" +
"
"width='150' />" +
"
"width='150' " +
"disableSorting='1' />" +
"" +
"";
Xrm.Page.getControl("parentaccountid").addCustomView(viewId, "account", viewDisplayName, fetchXml, layoutXml, true);
Sets the viewId, viewDisplayName, fetchXml, and layoutXml variables to pass as arguments so that a custom view is added as the default view to the control for theParent Account lookup field. Hope it helps.
コメント