我已经建立了一个将由功能区中的按钮调用的进程。我已经将它添加到表单视图中,没有问题,我希望它也可以从网格视图中工作。
问题是我在实际过程开始之前验证了一些数据。在可视功能区中,我将 SelectedControlSelectedItemIds 作为参数传递,并且仅在仅选择一条记录时才启用该按钮。
调用的 JS 如下所示:
function AutoQualify(dialogId, typeName, recordId, width, heigth) {
retrieveLeadRecord(recordId);
var stateCode = getLeadStateCode(recordId)
if ((stateCode === null) || (stateCode === undefined) || (stateCode === "")) {
alert("status Code fält kan inte vara tömt");
return;
}
if ((stateCode != 0)) {
alert("Man kan inte köra Quicksale från ett kvalificerat Lead");
return;
}
var firstName = GetAttributeValue('firstname');
if ((firstName === null) || (firstName === undefined) || (firstName === "")) {
alert("Förstanamn fält kan inte vara tömt");
return;
}
var lastName = GetAttributeValue('lastname');
if ((lastName === null) || (lastName === undefined) || (lastName === "")){
alert("Efternamn fält kan inte vara tömt");
return;
}
var companyName = GetAttributeValue('companyname');
if ((companyName === null) || (companyName === undefined) || (companyName === "")) {
alert("Företagsnamn fält kan inte vara tömt");
return;
}
var orgNummer = GetAttributeValue('custom_corporateidentificationnumber');
if ((orgNummer === null) || (orgNummer === undefined) || (orgNummer === "")) {
alert("Organisationsnummer fält kan inte vara tömt");
return;
}
var leadSourceCode = GetAttributeValue('leadsourcecode');
if ((leadSourceCode === null) || (leadSourceCode === undefined) || (leadSourceCode === "")) {
alert("Leadskälla fält kan inte vara tömt");
return;
}
var mailAddress = GetAttributeValue('emailaddress1');
var telephone = GetAttributeValue('telephone1');
if (((mailAddress === null) || (mailAddress === undefined) || (mailAddress === "")) && ((telephone === null) || (telephone === undefined) || (telephone === ""))) {
alert("Man måste ange e-post adress eller telefonnummer");
return;
}
if (confirm("Vill du kvalificera leadet?")) {
LaunchModalDialogChangeSize(dialogId, typeName, recordId, width, heigth, Xrm.Page.context.getServerUrl() );
}
}
检索用户记录函数:
function retrieveLeadRecord(Id) {
var serverUrl = Xrm.Page.context.getServerUrl();
var GlobalODataPath = serverUrl + "/XRMServices/2011/OrganizationData.svc";
var select = "/LeadSet?$select=StateCode,StatusCode&$filter=LeadId eq guid'" + Id + "'";
showMessage("retrieveLead function START");
var retrieveLeadReq = new XMLHttpRequest();
retrieveLeadReq.open("GET", GlobalODataPath + select, true);
retrieveLeadReq.setRequestHeader("Accept", "application/json");
retrieveLeadReq.setRequestHeader("Content-Type", "application/json; charset=utf-8");
alert("3");
retrieveLeadReq.onreadystatechange = function () {
retrieveLeadReqCallBack(this);
};
retrieveLeadReq.send();
showMessage("retrieveLead function END.");
}
但永远不会超过 XMLHttpRequest 声明。缺少图书馆吗?