问题描述
以当事件被激发的时候,代码将会执行创建并打开一个新的联系人记录。为例
解决方案
解决方案二:
该示例演示了如何在客户端使用CrmService.Create方法来创建联系人。如何测试:1:将下面的代码粘贴到“事件详细信息属性”对话框的客户端事件中。[JScript]//Preparevaluesforthenewcontact.varfirstname="Jesper";varlastname="Aaberg";vardonotbulkemail="true";varaddress1_stateorprovince="MT";varaddress1_postalcode="99999";varaddress1_line1="23MarketSt.";varaddress1_city="Sammamish";varauthenticationHeader=GenerateAuthenticationHeader();//PreparetheSOAPmessage.varxml="<?xmlversion='1.0'encoding='utf-8'?>"+"<soap:Envelopexmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+"xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+authenticationHeader+"<soap:Body>"+"<Createxmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+"<entityxsi:type='contact'>"+"<address1_city>"+address1_city+"</address1_city>"+"<address1_line1>"+address1_line1+"</address1_line1>"+"<address1_postalcode>"+address1_postalcode+"</address1_postalcode>"+"<address1_stateorprovince>"+address1_stateorprovince+"</address1_stateorprovince>"+"<donotbulkemail>"+donotbulkemail+"</donotbulkemail>"+"<firstname>"+firstname+"</firstname>"+"<lastname>"+lastname+"</lastname>"+"</entity>"+"</Create>"+"</soap:Body>"+"</soap:Envelope>";//PreparethexmlHttpObjectandsendtherequest.varxHReq=newActiveXObject("Msxml2.XMLHTTP");xHReq.Open("POST","/mscrmservices/2007/CrmService.asmx",false);xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Create");xHReq.setRequestHeader("Content-Type","text/xml;charset=utf-8");xHReq.setRequestHeader("Content-Length",xml.length);xHReq.send(xml);//CapturetheresultvarresultXml=xHReq.responseXML;//Checkforerrors.varerrorCount=resultXml.selectNodes('//error').length;if(errorCount!=0){varmsg=resultXml.selectSingleNode('//description').nodeTypedValue;alert(msg);}//Opennewcontactrecordifnoerrors.else{varcontactid=resultXml.selectSingleNode("//CreateResult");window.open("/sfa/conts/edit.aspx?id={"+contactid.nodeTypedValue+"}");}AsuccessfulresponseincludesXMLwithaCreateResponseelementthatreturnstheIDfortherecordcreated.Thefollowingisanexampleofasuccessfulresponse:<?xmlversion="1.0"encoding="utf-8"?><soap:Envelopexmlns: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:Body><CreateResponsexmlns="http://schemas.microsoft.com/crm/2007/WebServices"><CreateResult>368c8b1b-851c-dd11-ad3a-0003ff9ee217</CreateResult></CreateResponse></soap:Body></soap:Envelope>
解决方案三:
获取可用分