CRM4里获取字段的值是
1.crmForm.all.字段名.DataValue
var xml = "" + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + " <soap:Header>" + " <CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + " <AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>" + " <OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">crm4</OrganizationName>" + " <CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">00000000-0000-0000-0000-000000000000</CallerId>" + " </CrmAuthenticationToken>" + " </soap:Header>" + " <soap:Body>" + " <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + " <entityName>account</entityName>" + " <id>01394f69-8c12-e211-973b-080027a95e25</id>" + " <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\">" + " <q1:Attributes>" + " <q1:Attribute>primarycontactid</q1:Attribute>" + " </q1:Attributes>" + " </columnSet>" + " </Retrieve>" + " </soap:Body>" + "</soap:Envelope>" + ""; var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve"); xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlHttpRequest.setRequestHeader("Content-Length", xml.length); xmlHttpRequest.send(xml); var resultXml = xmlHttpRequest.responseXML; alert(resultXml.xml); <soap:Header>" + " <CrmAuthenticationToken xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + " <AuthenticationType xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">0</AuthenticationType>" + " <OrganizationName xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">crm4</OrganizationName>" + " <CallerId xmlns=\"http://schemas.microsoft.com/crm/2007/CoreTypes\">00000000-0000-0000-0000-000000000000</CallerId>" + " </CrmAuthenticationToken>" + " </soap:Header> 等价于 GenerateAuthenticationHeader()
2.CRM4.0 客户实体中 选择上级联系人(lookup类型),把主要联系人(lookup类型)的值也带出来?
//ParentAccountOnchange
window.ParentAccountOnchange = function () { debugger; var oField = event.srcElement; if (typeof (oField) != "undefined" && oField != null) { var obj = oField.DataValue; var id = obj[0].id; var xml = "" + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" + GenerateAuthenticationHeader() + " <soap:Body>" + " <Retrieve xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" + " <entityName>account</entityName>" + " <id>" + id + "</id>" + " <columnSet xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:ColumnSet\">" + " <q1:Attributes>" + " <q1:Attribute>primarycontactid</q1:Attribute>" + " </q1:Attributes>" + " </columnSet>" + " </Retrieve>" + " </soap:Body>" + "</soap:Envelope>" + ""; var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Retrieve"); xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlHttpRequest.setRequestHeader("Content-Length", xml.length); xmlHttpRequest.send(xml); var resultXml = xmlHttpRequest.responseXML; if (resultXml.selectSingleNode("//q1:primarycontactid") == null) { crmForm.all.primarycontactid.DataValue = null; return; } var contactName = resultXml.selectSingleNode("//q1:primarycontactid").getAttribute("name"); var contactId = resultXml.selectSingleNode("//q1:primarycontactid").text; var lookupItem = new Array(); var lookup = new Object(); lookup.typename = "contact"; lookup.id = contactId; lookup.name = contactName; lookupItem[0] = lookup; crmForm.all.primarycontactid.DataValue = lookupItem; } }
//注册事件
crmForm.all.parentaccountid.attachEvent('onchange', ParentAccountOnchange);
3.Javascript 获取服务器的时间
GetServerDateTime = function() { var returnValue = null; var xml = "<?xml version='1.0' encoding='utf-8'?>" + "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" + GenerateAuthenticationHeader() + "<soap:Body>" + "<GetServerTime xmlns='http://Www.Frensworkz.Com.Crm40.WebService/' />" + "</soap:Body>" + "</soap:Envelope>"; var xHReq = new ActiveXObject("Msxml2.XMLHTTP"); xHReq.Open("POST", "/ISV/ExtensionWebService/GetServerTimeService.asmx", false); xHReq.setRequestHeader("SOAPAction", "http://Www.Frensworkz.Com.Crm40.WebService/GetServerTime"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xHReq.setRequestHeader("Content-Length", xml.length); xHReq.send(xml); var resultXml = xHReq.responseXML; var errorCount = resultXml.selectNodes('//error').length; if (errorCount != 0) { var msg = resultXml.selectSingleNode('//description').nodeTypedValue; alert(msg); } else { returnValue = new Date(Date.parse(resultXml.text.replace(/-/g, "/"))); } return returnValue; }
4.查询多条记录
RetrieveQueryRecords = function(fetchXmlStr) { var returnResults = null; var xml = "<?xml version='1.0' encoding='utf-8'?>" + "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" + GenerateAuthenticationHeader() + "<soap:Body>" + "<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>" + "<fetchXml>" + fetchXmlStr + "</fetchXml>" + "</Fetch>" + "</soap:Body>" + "</soap:Envelope>"; var xHReq = new ActiveXObject("Msxml2.XMLHTTP"); xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false); xHReq.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Fetch"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xHReq.setRequestHeader("Content-Length", xml.length); xHReq.send(xml); var resultXml = xHReq.responseXML; var errorCount = resultXml.selectNodes('//error').length; if (errorCount != 0) { var msg = resultXml.selectSingleNode('//description').nodeTypedValue; alert(msg); } else { var resultSet = new String(); resultSet = resultXml.text; resultSet.replace('<', '<'); resultSet.replace('>', '>'); var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM"); oXmlDoc.async = false; oXmlDoc.loadXML(resultSet); returnResults = oXmlDoc.getElementsByTagName('result'); } return returnResults; }
5.检查角色
function HaveCheckRole() { var returnValue = 0; //""系统管理员""总部 var FetchXmlStr = "<fetch mapping='logical' aggregate='true'>" + "<entity name='role'>" + " <attribute name='roleid' aggregate='count' alias='HaveRole' />" + " <filter type='or'>" + " <condition attribute='name' operator='eq' value='系统管理员' />" + " <condition attribute='name' operator='eq' value='总部' />" + " </filter>" + "<link-entity name='systemuserroles' from='roleid' to='roleid'>" + " <filter>" + " <condition attribute='systemuserid' operator='eq-userid' />" + " </filter>" + "</link-entity>" + "</entity>" + "</fetch>"; var results = RetrieveQueryRecords(FetchXmlStr); returnValue = results[0].selectSingleNode('./HaveRole').nodeTypedValue; return returnValue; }
6.当前登录人身份
function GetCurrentUserId() { var returnValue = 0; //当前登录人身份 var FetchXmlStr = "<fetch mapping='logical' >" + "<entity name='systemuser'>" + " <attribute name='systemuserid' />" + " <filter>" + " <condition attribute='systemuserid' operator='eq-userid' />" + " </filter>" + "</entity>" + "</fetch>"; var results = RetrieveQueryRecords(FetchXmlStr); returnValue = results[0].selectSingleNode('./systemuserid').nodeTypedValue; return returnValue; }
7.公共JS方法
GetCityForMobile = function(telNo) { var returnValue = null; var xml = "<?xml version='1.0' encoding='utf-8'?>" + "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" + GenerateAuthenticationHeader() + "<soap:Body>" + "<GetCrmCTIAddrService xmlns='http://Www.Frensworkz.Com.Crm40.WebService/'>" + "<telNo>" + telNo + "</telNo>" + "</GetCrmCTIAddrService>" + "</soap:Body>" + "</soap:Envelope>"; var xHReq = new ActiveXObject("Msxml2.XMLHTTP"); xHReq.Open("POST", "/ISV/ExtensionWebService/CTIService.asmx", false); xHReq.setRequestHeader("SOAPAction", "http://Www.Frensworkz.Com.Crm40.WebService/GetCrmCTIAddrService"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xHReq.setRequestHeader("Content-Length", xml.length); xHReq.send(xml); var resultXml = xHReq.responseXML; var errorCount = resultXml.selectNodes('//error').length; if (errorCount != 0) { var msg = resultXml.selectSingleNode('//description').nodeTypedValue; alert(msg); } else { returnValue = resultXml.text.replace(/-/g, "/"); } return returnValue; } RetrieveSingleEntity = function(entityName, entityId, columnSet) { var soapNS = "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""; var xsiNS = "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""; var xsdNS = "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""; var defaultNS = "xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\""; var queryNS = "xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\""; var async = false; var sMessage = BuildStart() + BuildBody(entityName, entityId, columnSet) + BuildEnd(); var oHttp = new ActiveXObject("Msxml2.XMLHTTP"); SendMessage(oHttp); return BuildResult(oHttp); function SendMessage(oHttp) { var url = "/mscrmservices/2007/crmservice.asmx"; oHttp.open("POST", url, async); oHttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute"); oHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); oHttp.setRequestHeader("Content-Length", sMessage.length); oHttp.Send(sMessage); } function BuildResult(oHttp) { var response = oHttp.responseText; var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); xmlDoc.async = async; xmlDoc.loadXML(response); if (xmlDoc.parseError.errorCode != 0) { var xmlErr = xmlDoc.parseError; alert("Error retrieving Recipient: " + xmlErr.reason); } else { var arrResult = new Array(); var returnNode = xmlDoc.documentElement.selectSingleNode("/soap:Envelope/soap:Body/ExecuteResponse/Response/BusinessEntity/Properties"); for (var i = 0; i < returnNode.childNodes.length; i++) { arrResult[i] = new Array(); arrResult[i][0] = returnNode.childNodes[i].attributes[1].value; arrResult[i][1] = returnNode.childNodes[i].text; if (returnNode.childNodes[i].attributes[0].value == "PicklistProperty") { if (returnNode.childNodes[i].childNodes[0].attributes[0] != undefined) { arrResult[i][2] = returnNode.childNodes[i].childNodes[0].attributes[0].value; } } if (returnNode.childNodes[i].attributes[0].value == "LookupProperty" || returnNode.childNodes[i].attributes[0].value == "OwnerProperty") { if (returnNode.childNodes[i].childNodes[0].attributes[0] != undefined) { arrResult[i][2] = returnNode.childNodes[i].childNodes[0].attributes[0].value; if (returnNode.childNodes[i].childNodes[0].attributes[1] != undefined) { arrResult[i][3] = returnNode.childNodes[i].childNodes[0].attributes[1].value; } } } } } return arrResult; } function BuildStart() { var sMessage = ""; sMessage += "<soap:Envelope "; sMessage += soapNS + " "; sMessage += xsiNS + " "; sMessage += xsdNS + ">"; sMessage += GenerateAuthenticationHeader(); return sMessage; } function BuildBody(entityName, entityId, columnSet) { var sMessage = ""; sMessage += "<soap:Body>"; sMessage += "<Execute " + defaultNS + ">"; sMessage += "<Request xsi:type=\"RetrieveRequest\" ReturnDynamicEntities=\"true\">"; sMessage += "<OptionalParameters>"; sMessage += "<OptionalParameter xsi:nil=\"true\" />"; sMessage += "</OptionalParameters>"; sMessage += "<Target xsi:type=\"TargetRetrieveDynamic\">"; sMessage += "<EntityName>" + entityName + "</EntityName>"; sMessage += "<EntityId>" + entityId + "</EntityId>"; sMessage += "</Target>"; if (columnSet == null || columnSet.length == 0) { sMessage += "<ColumnSet " + queryNS + " xsi:type=\"q1:AllColumns\" />"; } else { sMessage += "<ColumnSet " + queryNS + " xsi:type=\"q1:ColumnSet\">"; sMessage += "<q1:Attributes>"; for (var i = 0; i < columnSet.length; i++) { sMessage += "<q1:Attribute>"; sMessage += columnSet[i]; sMessage += "</q1:Attribute>"; } sMessage += "</q1:Attributes>"; sMessage += "</ColumnSet>"; } sMessage += "</Request>"; sMessage += "</Execute>"; sMessage += "</soap:Body>"; return sMessage; } function BuildEnd() { return "</soap:Envelope>"; } } GetLookupFieldValue = function(oResult, fieldScheduleName) { for (var i = 0; i < oResult.length; i++) { if (oResult[i] == undefined) { continue; } if (oResult[i][0] == undefined) { continue; } if (oResult[i][0] == fieldScheduleName) { var item = new Object(); item.id = oResult[i][1]; item.name = oResult[i][2]; item.typename = oResult[i][3]; var data = new Array(); data[0] = item; break; } } return data; } GetPicklistFieldValue = function(oResult, fieldScheduleName) { for (var i = 0; i < oResult.length; i++) { if (oResult[i] == undefined) { continue; } if (oResult[i][0] == undefined) { continue; } if (oResult[i][0] == fieldScheduleName) { var item = new Object(); item.value = oResult[i][1]; item.selectedtext = oResult[i][2]; var data = new Array(); data[0] = item; break; } } return data; } GetFieldValue = function(oResult, fieldScheduleName) { var fieldValue; for (var i = 0; i < oResult.length; i++) { if (oResult[i] == undefined) { continue; } if (oResult[i][0] == undefined) { continue; } if (oResult[i][0] == fieldScheduleName) { fieldValue = oResult[i][1]; break; } } return fieldValue; }
8.JS
GetCityForMobile = function(telNo) { var returnValue = null; var xml = "<?xml version='1.0' encoding='utf-8'?>" + "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'" + " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>" + GenerateAuthenticationHeader() + "<soap:Body>" + "<GetCrmCTIAddrService xmlns='http://Www.Frensworkz.Com.Crm40.WebService/'>" + "<telNo>" + telNo + "</telNo>" + "</GetCrmCTIAddrService>" + "</soap:Body>" + "</soap:Envelope>"; var xHReq = new ActiveXObject("Msxml2.XMLHTTP"); xHReq.Open("POST", "/ISV/ExtensionWebService/CTIService.asmx", false); xHReq.setRequestHeader("SOAPAction", "http://Www.Frensworkz.Com.Crm40.WebService/GetCrmCTIAddrService"); xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xHReq.setRequestHeader("Content-Length", xml.length); xHReq.send(xml); var resultXml = xHReq.responseXML; var errorCount = resultXml.selectNodes('//error').length; if (errorCount != 0) { var msg = resultXml.selectSingleNode('//description').nodeTypedValue; alert(msg); } else { returnValue = resultXml.text.replace(/-/g, "/"); } return returnValue; } RetrieveSingleEntity = function(entityName, entityId, columnSet) { var soapNS = "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""; var xsiNS = "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""; var xsdNS = "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""; var defaultNS = "xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\""; var queryNS = "xmlns:q1=\"http://schemas.microsoft.com/crm/2006/Query\""; var async = false; var sMessage = BuildStart() + BuildBody(entityName, entityId, columnSet) + BuildEnd(); var oHttp = new ActiveXObject("Msxml2.XMLHTTP"); SendMessage(oHttp); return BuildResult(oHttp); function SendMessage(oHttp) { var url = "/mscrmservices/2007/crmservice.asmx"; oHttp.open("POST", url, async); oHttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute"); oHttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); oHttp.setRequestHeader("Content-Length", sMessage.length); oHttp.Send(sMessage); } function BuildResult(oHttp) { var response = oHttp.responseText; var xmlDoc = new ActiveXObject("Msxml2.DOMDocument"); xmlDoc.async = async; xmlDoc.loadXML(response); if (xmlDoc.parseError.errorCode != 0) { var xmlErr = xmlDoc.parseError; alert("Error retrieving Recipient: " + xmlErr.reason); } else { var arrResult = new Array(); var returnNode = xmlDoc.documentElement.selectSingleNode("/soap:Envelope/soap:Body/ExecuteResponse/Response/BusinessEntity/Properties"); for (var i = 0; i < returnNode.childNodes.length; i++) { arrResult[i] = new Array(); arrResult[i][0] = returnNode.childNodes[i].attributes[1].value; arrResult[i][1] = returnNode.childNodes[i].text; if (returnNode.childNodes[i].attributes[0].value == "PicklistProperty") { if (returnNode.childNodes[i].childNodes[0].attributes[0] != undefined) { arrResult[i][2] = returnNode.childNodes[i].childNodes[0].attributes[0].value; } } if (returnNode.childNodes[i].attributes[0].value == "LookupProperty" || returnNode.childNodes[i].attributes[0].value == "OwnerProperty") { if (returnNode.childNodes[i].childNodes[0].attributes[0] != undefined) { arrResult[i][2] = returnNode.childNodes[i].childNodes[0].attributes[0].value; if (returnNode.childNodes[i].childNodes[0].attributes[1] != undefined) { arrResult[i][3] = returnNode.childNodes[i].childNodes[0].attributes[1].value; } } } } } return arrResult; } function BuildStart() { var sMessage = ""; sMessage += "<soap:Envelope "; sMessage += soapNS + " "; sMessage += xsiNS + " "; sMessage += xsdNS + ">"; sMessage += GenerateAuthenticationHeader(); return sMessage; } function BuildBody(entityName, entityId, columnSet) { var sMessage = ""; sMessage += "<soap:Body>"; sMessage += "<Execute " + defaultNS + ">"; sMessage += "<Request xsi:type=\"RetrieveRequest\" ReturnDynamicEntities=\"true\">"; sMessage += "<OptionalParameters>"; sMessage += "<OptionalParameter xsi:nil=\"true\" />"; sMessage += "</OptionalParameters>"; sMessage += "<Target xsi:type=\"TargetRetrieveDynamic\">"; sMessage += "<EntityName>" + entityName + "</EntityName>"; sMessage += "<EntityId>" + entityId + "</EntityId>"; sMessage += "</Target>"; if (columnSet == null || columnSet.length == 0) { sMessage += "<ColumnSet " + queryNS + " xsi:type=\"q1:AllColumns\" />"; } else { sMessage += "<ColumnSet " + queryNS + " xsi:type=\"q1:ColumnSet\">"; sMessage += "<q1:Attributes>"; for (var i = 0; i < columnSet.length; i++) { sMessage += "<q1:Attribute>"; sMessage += columnSet[i]; sMessage += "</q1:Attribute>"; } sMessage += "</q1:Attributes>"; sMessage += "</ColumnSet>"; } sMessage += "</Request>"; sMessage += "</Execute>"; sMessage += "</soap:Body>"; return sMessage; } function BuildEnd() { return "</soap:Envelope>"; } } GetLookupFieldValue = function(oResult, fieldScheduleName) { for (var i = 0; i < oResult.length; i++) { if (oResult[i] == undefined) { continue; } if (oResult[i][0] == undefined) { continue; } if (oResult[i][0] == fieldScheduleName) { var item = new Object(); item.id = oResult[i][1]; item.name = oResult[i][2]; item.typename = oResult[i][3]; var data = new Array(); data[0] = item; break; } } return data; } GetPicklistFieldValue = function(oResult, fieldScheduleName) { for (var i = 0; i < oResult.length; i++) { if (oResult[i] == undefined) { continue; } if (oResult[i][0] == undefined) { continue; } if (oResult[i][0] == fieldScheduleName) { var item = new Object(); item.value = oResult[i][1]; item.selectedtext = oResult[i][2]; var data = new Array(); data[0] = item; break; } } return data; } GetFieldValue = function(oResult, fieldScheduleName) { var fieldValue; for (var i = 0; i < oResult.length; i++) { if (oResult[i] == undefined) { continue; } if (oResult[i][0] == undefined) { continue; } if (oResult[i][0] == fieldScheduleName) { fieldValue = oResult[i][1]; break; } } return fieldValue; } var CRM_FORM_TYPE_CREATE = 1; var CRM_FORM_TYPE_UPDATE = 2; var CallInNum = "0"; var CallOutNum = "0"; var CallReleaseNum = "0"; var CallTransferNum = "0"; var new_source_problem = crmForm.all.new_source_problem; //来源问题比环 var new_customer = crmForm.all.new_customer; //客户 var new_out_tel_content = crmForm.all.new_customer; //来源出电计划 var new_content = crmForm.all.new_content; //出电内容 var new_out_tel_staus = crmForm.all.new_out_tel_staus; //是否完成 var new_date = crmForm.all.new_date; //计划完成时间 var new_source = crmForm.all.new_source; //来源 var new_category = crmForm.all.new_category; //类别 var new_information_record = crmForm.all.new_information_record; //信息增值记录 var new_get_information = crmForm.all.new_get_information; //获取信息 var new_tel = crmForm.all.new_tel; //电话 var new_contect = crmForm.all.new_contect; //联系人 var new_primary_audioid = crmForm.all.new_primary_audioid; //本通电话录音主ID var new_transferno = crmForm.all.new_transferno; //待转入分机号 var IFRAME_CallCtrl = crmForm.all.IFRAME_CallCtrl; //关闭进出电 var haiertab1_visible = document.getElementById("{9c59be20-10b6-de11-b047-00215e547af2}"); //关闭进出电 if (crmForm.FormType == CRM_FORM_TYPE_CREATE) { new_date.DataValue = Date.parse(new Date().toDateString()); //new_contect.Disabled = true; //new_tel.Disabled = true; new_source_problem.Disabled = true; new_out_tel_staus.Disabled = true; if (new_contect.DataValue != null) { var arrColumnSet = new Array(); arrColumnSet.push("fullname"); var OResult = RetrieveSingleEntity("contact", new_contect.DataValue[0].id, arrColumnSet); var new_contectLookup = new Array(); new_contectLookup = GetLookupFieldValue(OResult, "fullname"); new_contectLookup[0].name = new_contectLookup[0].id; new_contectLookup[0].id = new_contect.DataValue[0].id; new_contectLookup[0].typename = new_contect.DataValue[0].typename; new_contect.DataValue = new_contectLookup; } if (new_source_problem.DataValue != null && new_out_tel_content.DataValue == null) { var arrColumnSet = new Array(); arrColumnSet.push("new_belongtoaccount"); //问题比环-客户 var OResult = RetrieveSingleEntity("new_problem_close", new_source_problem.DataValue[0].id, arrColumnSet); var new_customerLookup = new Array(); //问题比环-客户 new_customerLookup = GetLookupFieldValue(OResult, "new_belongtoaccount"); if (new_customerLookup != null) { new_customer.DataValue = new_customerLookup; new_customer_onchange0(); new_customer.Disabled = true; new_customer.ForceSubmit = true; } new_source.DataValue = 2; new_content.SetFocus(); } if (new_out_tel_content.DataValue != null) { new_source.DataValue = 2; } } else if (crmForm.FormType == CRM_FORM_TYPE_UPDATE) { new_customer.Disabled = true; new_date.Disabled = true; new_contect.Disabled = true; new_source_problem.Disabled = true; new_source.Disabled = true; if (new_out_tel_staus.DataValue == 2 || new_out_tel_staus.DataValue == 4) { new_content.Disabled = true; new_out_tel_staus.Disabled = true; new_source.Disabled = true; new_category.Disabled = true; new_information_record.Disabled = true; new_get_information.Disabled = true; } else { new_out_tel_staus.DeleteOption(4); } } if (crmForm.FormType != CRM_FORM_TYPE_CREATE) { SetsalestihuodanIFame(); } function SetsalestihuodanIFame() { try { var sArea = "new_new_out_tel_new_sales_order"; var sBaseUrl = "areas.aspx?"; var html = sBaseUrl; html += "oId=" + crmForm.ObjectId; html += "&oType=" + crmForm.ObjectTypeCode; html += "&security=" + crmFormSubmit.crmFormSubmitSecurity.value; html += "&roleOrd=1"; html += "&tabSet=" + sArea; crmForm.all.IFRAME_salesorder.src = html; } catch (err) { alert(err.description); } } if (new_customer.DataValue != null) { IFRAME_CallCtrl.src = "/isv/DynamicInCallList.aspx?contactid=" + new_customer.DataValue[0].id + "&telid=" + crmForm.ObjectId; } else { haiertab1_visible.style.display = "none"; } CallInTelAudio = function() { try { var audioid = ccApp.edu_GetValueByName('voice.1.ucid'); new_primary_audioid.DataValue = audioid + ""; new_primary_audioid.ForceSubmit = true; } catch (err) { alert(err.message); } } CallOutTelAudio = function() { try { var audioid = ccApp.edu_GetValueByName('voice.1.ucid'); new_primary_audioid.DataValue = audioid + ""; new_primary_audioid.ForceSubmit = true; } catch (err) { alert(err.message); } } CTICallOut = function() { if (CallOutNum == "0") { var isNumeric = /^\d{7,12}$/; if (new_tel.DataValue != null && new_tel.DataValue != "" && isNumeric.test(new_tel.DataValue)) { CallOutNum = "1"; try { var TelNumber = new_tel.DataValue; if (TelNumber.length == 11 && TelNumber.substring(0, 1) == "1") { if (GetCityForMobile(TelNumber) == "青岛") { getccApp(); ccApp.ch_MakeCall("0" + TelNumber); window.setTimeout("CallOutTelAudio()", 10000); } else { getccApp(); ccApp.ch_MakeCall("00" + TelNumber); window.setTimeout("CallOutTelAudio()", 10000); } } else { getccApp(); ccApp.ch_MakeCall("0" + TelNumber); window.setTimeout("CallOutTelAudio()", 10000); } } catch (err) { alert("未正确加载CTI控件,请确认是否已经签入CTI,并置空闲状态后重试?"); } } else { alert("无法呼出,请确认呼出电话号码正确后重试!"); } } else { alert("你已经点击'呼出'功能按钮,电话可能已经正在拨打中或已拨打!(会覆盖之前的录音记录绑定)\r\n请确认该客户没有接通该电话(即还没有记录录音),请点击'软电话重置'按钮后重试!"); } } CTICallIn = function() { if (CallInNum == "0") { CallInNum = "1"; try { getccApp(); ccApp.wi_Accept(); CallInTelAudio(); } catch (err) { alert("未正确加载CTI控件,请确认是否已经签入CTI,并置空闲状态?"); } } else { alert("你已经点击'应答'功能按钮,电话正在接通中,不能多次重复点击!\r\n如果还未能接通本电话,请点击'软电话重置'按钮后重试!"); } } CTICallRelease = function() { if (CallReleaseNum == "0") { CallReleaseNum = "1"; try { getccApp(); ccApp.wi_Release(); } catch (err) { CallReleaseNum = "0"; } } else { alert("你已经点击'挂机'功能按钮,电话正在挂机中,不能多次重复点击!\r\n如果还未能挂断本通电话,请点击'软电话重置'按钮后重试!"); } } CTICallTransfer = function() { if (CallTransferNum == "0") { var isNumeric = /^\d{4}$/; if (new_transferno.DataValue != null && new_transferno.DataValue != "" && isNumeric.test(new_transferno.DataValue)) { try { CallTransferNum = "1"; getccApp(); ccApp.wi_Transfer(new_transferno.DataValue, "Frensworkz CRM Transfer Call!"); } catch (err) { alert("未正确加载CTI控件,请确认是否已经签入CTI,并置空闲状态?"); } } else { alert("请正确输入需要转入的分机号码(4位数字)!"); } } else { alert("你已经点击'转出'功能按钮,如电话未能成功转出还需重新转出,请点击'软电话重置'功能按钮后重试!"); } } CTICallRefresh = function() { CallInNum = "0"; CallOutNum = "0"; CallReleaseNum = "0" CallTransferNum = "0"; }