Dynamics crm 2011 需要帮助:联系电话中的帐户名
我是CRM新手,到目前为止,我已经能够解决所有问题。我读过很多帖子和网络帖子,并尝试过。我看了很多视频。看起来应该很容易。联系人记录具有ParentCustomerID和ParentCustomerName,如果存在关联帐户,则该帐户将由ParentCustomerName保存。现在,我完全搞不清楚所需的步骤 要求:-我需要帐户名显示在联系人级别的电话呼叫表单上,并保存在电话呼叫表中,以便在电话呼叫视图中可见 我在电话呼叫N:1关系字段str_companyid查找中有一个主要实体是具有引用行为的帐户 我尝试了一个电话N:1关系字段new_companystring查找主要实体是具有引用行为的联系人。我得出的结论是,这不是一个有效的方法。如果不正确,请告诉我 我需要N:N吗 我已将str_companyid字段添加到表单中。我转到“为联系人工作流创建电话”流程。在createphonecall步骤中,我添加了动态字段{CompanyContact}。保存并发布后;我创建了一个电话,但没有填充 我尝试了不同的Web资源JS。我已经在表单属性的onload中添加了JS 为什么像这样简单的事情不管用?我似乎无法让检索记录正常工作。我也尝试过xmlHttpObject对象,但它返回0 有人能帮我解决我所缺少的问题吗?实现这一目标的完整步骤是什么? ![我有下面的截图和我运行的代码][1]Dynamics crm 2011 需要帮助:联系电话中的帐户名,dynamics-crm-2011,Dynamics Crm 2011,我是CRM新手,到目前为止,我已经能够解决所有问题。我读过很多帖子和网络帖子,并尝试过。我看了很多视频。看起来应该很容易。联系人记录具有ParentCustomerID和ParentCustomerName,如果存在关联帐户,则该帐户将由ParentCustomerName保存。现在,我完全搞不清楚所需的步骤 要求:-我需要帐户名显示在联系人级别的电话呼叫表单上,并保存在电话呼叫表中,以便在电话呼叫视图中可见 我在电话呼叫N:1关系字段str_companyid查找中有一个主要实体是具有引用行为
function PopulateCompanyName()
{
//get group GUID
if (Xrm.Page.getAttribute("to").getValue()[0].id != null) {
var lookup = Xrm.Page.getAttribute("to").getValue();
alert(lookup[0].id);
alert(lookup[0].typename);
alert(lookup[0].name);
alert(lookup);
SDK.JQuery.retrieveRecord(lookup[0].id,
lookup[0].typename,
"ParentCustomerID",
null,
function (lookup) {
Xrm.Page.getAttribute("Company").setValue(lookup[0].str_companyid);
});
}
else {
Xrm.Page.getAttribute("str_companyid").setValue(null);
}
}
我在另一个论坛上回复了,但我在这里发布了更多的技术细节作为参考。 phonecall实体的to属性是partylist类型,这意味着它可以处理来自不同实体的多条记录。在您的情况下,如果联系人位于“收件人”字段内,则希望获取父帐户字段parentcustomerid 您的第一个代码包含相同的输入错误,并使用msdn检索示例,第二个代码使用CRM 4.0端点,它们在CRM 2011中仍然受支持,但最好避免使用它们,这样您就可以使用REST端点而不是SOAP端点 您的案例中的工作代码可以是: 函数setToParentAccount{ //仅当收件人字段有1条记录且是联系人时设置 如果Xrm.Page.getAttributeto.getValue!=null{ var recipient=Xrm.Page.getAttributeto.getValue; 如果recipient.length==1&&recipient[0]。entityType==联系人{ var contactId=收件人[0]。id; var-serverUrl; 如果Xrm.Page.context.getClientUrl!==未定义{ serverUrl=Xrm.Page.context.getClientUrl; }否则{ serverUrl=Xrm.Page.context.getServerUrl; } var ODataPath=serverUrl+/XRMServices/2011/OrganizationData.svc; var contactRequest=新的XMLHttpRequest; contactRequest.openGET,ODataPath+/ContactSetguid'+contactId+',false; contactRequest.setRequestHeaderAccept,application/json; contactRequest.setRequestHeaderContent-Type,application/json;字符集=utf-8; contactRequest.send; 如果contactRequest.status==200{ var retrievedContact=JSON.parsecontactRequest.responseText.d; var parentAccount=retrievedContact.ParentCustomerId; 如果parentAccount.Id!=null&&parentAccount.LogicalName==account{ var newParentAccount=新数组; newParentAccount[0]=新对象; newParentAccount[0]。id=parentAccount.id; newParentAccount[0]。名称=parentAccount.name; newParentAccount[0]。entityType=parentAccount.LogicalName; Xrm.Page.getAttributest_companyid.setValuenewParentAccount; }否则{ Xrm.Page.getAttributest_companyid.setValuenull; } }否则{ 警报错误; } }否则{ Xrm.Page.getAttributest_companyid.setValuenull; } } } 在to字段的OnLoad事件和OnChange事件中调用
function GetCompany()
///Get lookup ID
{
alert("I am Here");
var lookupfield = Xrm.Page.getAttribute("to").getValue();
if (lookupfield != null && lookupfield [0] != null)
{
var householdlookupvalue = lookupfield [0].id;
}
else
{
var householdlookupvalue = " ";
}
alert("I am here2");
alert(householdlookupvalue);
}
// Prepare variables for a contact to retrieve.
var authenticationHeader = Xrm.Page.context.getAuthenticationHeader();
// Prepare the SOAP message.
var xml = ""+
""+
authenticationHeader+
""+
""+
"contact"+
""+lookupfield [0].id+""+
""+
""+
"parentcustomerid"+
""+
""+
""+
""+
"";
alert(xml );
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
alert("at results");
var errorCount = resultXml.selectNodes('//error').length;
alert("errorCount " + errorCount); ////////////////////////////////////returns 0; it shouldn't
alert("After the result XML "+resultXml .toString() + " ::::");
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
}
// Display the retrieved value.
else
{
//Create an array to set as the DataValue for the lookup control.
var lookupData = new Array();
//Create an Object add to the array.
var lookupItem= new Object();
//Set the id, typename, and name properties to the object.
lookupItem.id = resultXml.selectSingleNode("//q1:parentcustomerid").nodeTypedValue;
lookupItem.entityType = 'account';
lookupItem.name = resultXml.selectSingleNode("//q1:parentcustomerid").getAttribute("name");
// Add the object to the array.
lookupData[0] = lookupItem;
alert(lookupitem.name)
// Set the value of the lookup field to the value of the array.
Xrm.Page.getAttribute("str_companyid").setValue(lookupData);
}
var contact = new Array();
contact = Xrm.Page.getAttribute("to").getValue();
alert("I am here");
alert(contact);
if (contact == null || contact[0].entityType != "contact" || contact.length > 1) {
return;
}
alert("inside if")
var serverUrl = Xrm.Page.context.getClientUrl();
var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/ContactSet?$select=ParentCustomerId&$filter=ContactId eq guid'" + contact[0].id + "'";
var retrieveReq = new XMLHttpRequest();
retrieveReq.open("GET", oDataSelect, false);
retrieveReq.setRequestHeader("Accept", "application/json");
retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");
retrieveReq.onreadystatechange = function () {
GetContactData(this);
};
retrieveReq.send();
}