gpt4 book ai didi

javascript - CRM 2013 查找中的 addCustomView

转载 作者:行者123 更新时间:2023-11-28 19:37:29 25 4
gpt4 key购买 nike

当我使用此代码为 CRM 2013 团队查找设置自定义 View 时,收到一条 Savedquery With Id = 00000000-0000-0000-0000-000000000000 不存在消息客户关系管理 2011。

// Set the Owning Team View based on the account selected
function setOwningTeamView(entityFieldName, lookupFieldName, resetSelection) {
// Get the selected entity
var account = Xrm.Page.getAttribute(entityFieldName).getValue();

if (account != null) {
var accid = account[0].id;
var accname = account[0].name;

if (resetSelection == true) {
// reset old selection for Contact
Xrm.Page.getAttribute(lookupFieldName).setValue(null);
}

// use randomly generated GUID Id for the view
var viewId = "{0CBC820C-7033-4AFF-9CE8-FB610464DBD3}";
var entityName = "team";

// give the custom view a name
var viewDisplayName = "Teams applicable to " + accname + "";

var accountBU = SDK.REST.retrieveRecordSync(Xrm.Page.getAttribute("a_account").getValue()[0].id, "Account", "OwningBusinessUnit", "");
var relatedBusinessUnits = SDK.REST.retrieveMultipleRecordsSync("BusinessUnit", "?$select=BusinessUnitId,Name&$filter=a_Type/Value eq 1");
var FetchXMLBU = "";
for (var i = 0; i < relatedBusinessUnits.results.length; i++) {
FetchXMLBU += "<value>" + relatedBusinessUnits.results[i].BusinessUnitId + "</value>"
}

debugger;

// find all contacts where parent customer is the account selected and where the Contact record is active
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"
+ "<entity name='team'>"
+ "<attribute name='teamid' />"
+ "<attribute name='name' />"
+ "<attribute name='description' />"
+ "<attribute name='businessunitid' />"
+ "<filter>"
+ "<condition attribute='businessunitid' operator='in'>"
+ "<value>" + accountBU.OwningBusinessUnit.Id + "</value>"
+ FetchXMLBU
+ "</condition>"
+ "</filter>"
+ "</entity>"
+ "</fetch>";

// build Grid Layout
var layoutXml = "<grid name='resultset' " +
"object='1' " +
"jump='teamid' " +
"select='1' " +
"icon='0' " +
"preview='0'>" +
"<row name='result' id='teamid'>" +
"<cell name='name' width='200' />" +
"<cell name='businessunitid' width='200' />" +
"<cell name='description' width='400' />" +
"</row>" +
"</grid>";

// add the Custom View to the indicated [lookupFieldName] Control
Xrm.Page.getControl(lookupFieldName).addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
//The following line is the an unsupported way of disabling the View Picker, currently there is no supported way.
document.getElementById(lookupFieldName + "_i").setAttribute("disableViewPicker", "1");
//document.getElementById(lookupFieldName).setAttribute("disableViewPicker", "1");
}
}

我怀疑问题出在对 SDK.REST 的调用上,如所解释的 in this thread ,但 accountBUrelatedBusinessUnits 中的结果是正确的。

我使用另一个 SDK 调用,其正确行为如下:

 var systemUserTeam = SDK.REST.retrieveMultipleRecordsSync("TeamMembership",
"$select=TeamId&$filter=TeamId eq guid'"
+ Xrm.Page.getAttribute("aux_owningteamid").getValue()[0].id
+ "' and SystemUserId eq guid'"
+ Xrm.Page.getAttribute("ownerid").getValue()[0].id
+ "'");
if (systemUserTeam.results.length != 1) {

我正在使用自定义 fetchXMLlaoyoutXML 设置 客户 查找 View ,方法相同除了对 SDK 的调用。

我可以对 SDK 调用进行哪些​​更改才能使其正常工作?

最佳答案

如果您不反对重写代码,现在有一种更简单且受支持的方法可以将自定义过滤器添加到查找中。您可以使用现有 View 并应用预过滤器。

This blog post提供了一个很好的例子。

关于javascript - CRM 2013 查找中的 addCustomView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25642195/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com