当用户在子网格中为多对多关系添加现有记录时,我想向弹出窗口添加自定义视图。
我按照以下链接上的说明进行操作
但是当我去添加现有记录时,它会引发一个通用错误,即不允许我下载日志文件。谁能指出我正确的方向以找出为什么这不起作用?
我将在下面发布代码。
function FilterSubGridLookup(gridTypeCode, gridControl, primaryEntity) {
if (primaryEntity != "ts_pmo_activity_request") {
Mscrm.GridRibbonActions.addExistingFromSubGridAssociated(gridTypeCode, gridControl);
}
else {
var fetchXml = '<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"> -<entity name="ts_qualification_area"> <attribute name="ts_qualification_areaid"/> <attribute name="ts_descriptor"/> <attribute name="createdon"/> <order descending="false" attribute="ts_descriptor"/> -<filter type="and"> <condition attribute="ts_solution_qualification_id" value="' + solutionQualificationId + '" uitype="ts_solution_qualification" operator="eq"/> </filter> </entity> </fetch>';
var layoutXml = "<grid name='resultset' object='1' jump='ts_qualification_areaid' select='1' icon='1' preview='1'><row name='result' id='ts_qualification_areaid'><cell name='ts_descriptor' width='150' /></row></grid>";
addExistingFromSubGridCustom(gridTypeCode, gridControl, fetchXml, layoutXml, "Filtered Qualification Areas");
}
}
function addExistingFromSubGridCustom(gridTypeCode, gridControl, fetch, layout, viewName) {
var viewId = "{1DFB2B35-B07C-44D1-868D-258DEEAB88E2}"; // a dummy view ID
var relName, roleOrd;
if (typeof (gridControl.GetParameter) === "function") { //post rollup 12
relName = gridControl.GetParameter("relName");
roleOrd = gridControl.GetParameter("roleOrd");
}
else { //pre rollup 12
relName = gridControl.getParameter("relName");
roleOrd = gridControl.getParameter("roleOrd");
}
//creates the custom view object
var customView = {
fetchXml: fetch,
id: viewId,
layoutXml: layout,
name: viewName,
recordType: gridTypeCode,
Type: 0
};
//pops the lookup window with our view injected
var lookupItems = LookupObjects(null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]);
//once the lookup window is closed, we need the parent record ID and ETC before associating selected records
if (lookupItems && lookupItems.items.length > 0) {
var parentId;
var parentTypeCode;
if (typeof (GetParentObject) == "function") { //post rollup 12 has its own function to get this
var parent = GetParentObject();
parentId = parent.id;
parentTypeCode = parent.objectTypeCode;
}
else { //pre rollup 12 still needs to use the old way
var parent = typeof (crmFormSubmit) == "undefined" ? $get("crmFormSubmit") : crmFormSubmit; //according to daniels blog crmFormSubmit should already be defined, but it's not...
if (parent) {
parentId = parent.crmFormSubmitId.value;
parentTypeCode = parent.crmFormSubmitObjectType.value;
}
else {
parentId = window.parent.crmFormSubmit.crmFormSubmitId.value;
parentTypeCode = window.parent.crmFormSubmit.crmFormSubmitObjectType.value;
}
}
//associates the selected records
AssociateObjects(parentTypeCode, parentId, gridTypeCode, lookupItems, IsNull(roleOrd) || roleOrd == 2, "", relName);
}
}