【发布时间】:2014-07-24 16:16:25
【问题描述】:
我们正在从 CRM 2011 迁移到 CRM 2013,这两个都是本地版本。我们使用 javascript 在案例表单上进行了功能区自定义,该功能加载了 N:N 关联帐户实体的自定义查找视图。在此自定义查找视图中,用户可以将选定的客户记录与当前案例相关联。
由于某种原因,此功能在 crm 2013 中不再起作用。自定义查找视图仍然正确加载,但由于某种原因,帐户记录不再与父案例记录关联。
我阅读了另一个关于此问题的问题,该问题由 Paul Nieuwelaar 使用以下链接解决: http://www.magnetismsolutions.co.nz/blog/paulnieuwelaar/2014/04/21/filter-n-n-add-existing-lookup-dynamics-crm-2013
基本上,“LookupObjects”功能在 CRM 2013 中不再起作用,必须替换为“LookupObjectsWithCallback”。
但是,即使遵循此解决方案,我仍然无法将客户记录与案例相关联。下面是我按照 Paul Nieuwelaar 的建议修改后的代码。我在这里错过了什么吗?如果 CRM 2011 版本仍在使用 Rollup 12,我什至包括在代码中,以防万一。我有一种感觉,这可能是因为脚本中没有正确提取父 Case。
谢谢,非常感谢任何帮助。
-伊丽莎白
function openAddLookupDialog(gridTypeCode) {
var relName = "new_account_incident";
var roleOrd = 2;
var viewId = "{00000000-0000-0000-00AA-000010001002}"; //dummy view ID
if (!IsNull(relName)) {
var customView = {
fetchXml: "{...}", //my FetchXML
id: viewId,
layoutXml: "{...}", //my layoutXml
name: "Filtered Lookup View",
recordType: gridTypeCode,
Type: 0
};
var parent = GetParentObject(null, 0);
var parameters = [gridTypeCode, "", relName, roleOrd, parent];
var callbackRef = Mscrm.Utilities.createCallbackFunctionObject("locAssocObjAction", this, parameters, false);
//pops the lookup window with our view injected
var lookupItems = LookupObjectsWithCallback(callbackRef, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]);
}
if (lookupItems && lookupItems.items.length > 0) {
//beginning of rollup 12 must make modification
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;
}
}//end of rollup 12 modification
//both of AssociateObjects that I try below here don't work
//AssociateObjects(crmFormSubmit.crmFormSubmitObjectType.value, crmFormSubmit.crmFormSubmitId.value, gridTypeCode, lookupItems, IsNull(roleOrd) || roleOrd == 2, "", relName);
AssociateObjects(parentTypeCode, parentId, gridTypeCode, lookupItems, IsNull(roleOrd) || roleOrd == 2, "", relName);
}
}
我们还修改了自定义.xml 文件,使其在单击按钮时触发 javascript。
<CommandDefinition Id="new.Form.incident.MainTab.Actions.AddExistingProperties.Command">
<EnableRules>
<EnableRule Id="new.Form.incident.MainTab.Actions.AddExistingProperties.Command.EnableRule.FormStateRule" />
<EnableRule Id="new.Form.incident.MainTab.Actions.AddExistingProperties.Command.EnableRule.ValueRule" />
</EnableRules>
<DisplayRules />
<Actions>
<JavaScriptFunction FunctionName="openAddLookupDialog" Library="$webresource:new_account_incident.js">
<IntParameter Value="1" />
</JavaScriptFunction>
</Actions>
【问题讨论】:
标签: javascript crm