问题描述
以当事件被激发的时候,代码将会执行查找负责人不是“Cannon”的客户的客户ID和名称。为例:
解决方案
解决方案二:
该示例演示了如何在客户端使用CrmService.Fetch方法来查询客户的属性。如何测试:1:将下面的代码粘贴到“事件详细信息属性”对话框的客户端事件中。2:启用事件并保存,然后通过“预览”选择“创建表单”来验证。代码如下[JScript]//Preparevariablestofetchaccounts.varfetchMapping="logical";varentityName="account";varfirstColumn="accountid";varsecondColumn="name";varlinkEntity="systemuser";varlinkEntityTo="owninguser";varfilterType="and";varconditionAttribute="lastname";varoperator="ne";varvalue="Cannon";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>"+"<Fetchxmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+"<fetchXml><fetchmapping='"+fetchMapping+"'>"+"<entityname='"+entityName+"'>"+"<attributename='"+firstColumn+"'/>"+"<attributename='"+secondColumn+"'/>"+"<link-entityname='"+linkEntity+"'to='"+linkEntityTo+"'>"+"<filtertype='"+filterType+"'>"+"<conditionattribute='"+conditionAttribute+"'"+"operator='"+operator+"'value='"+value+"'/>"+"</filter>"+"</link-entity>"+"</entity>"+"</fetch></fetchXml>"+"</Fetch>"+"</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/Fetch");xHReq.setRequestHeader("Content-Type","text/xml;charset=utf-8");xHReq.setRequestHeader("Content-Length",xml.length);xHReq.send(xml);//Capturetheresult.varresultXml=xHReq.responseXML;//Checkforerrors.varerrorCount=resultXml.selectNodes('//error').length;if(errorCount!=0){varmsg=resultXml.selectSingleNode('//description').nodeTypedValue;alert(msg);}//Processanddisplaytheresults.else{//CapturetheresultandUnEncodeit.varresultSet=newString();resultSet=resultXml.text;resultSet.replace('<','<');resultSet.replace('>','>');//CreateanXMLdocumentthatyoucanparse.varoXmlDoc=newActiveXObject("Microsoft.XMLDOM");oXmlDoc.async=false;//LoadtheXMLdocumentthathastheUnEncodedresults.oXmlDoc.loadXML(resultSet);//Displaytheresults.varresults=oXmlDoc.getElementsByTagName('result');varmsg="AccountIdttttAccountNamer";msg+="--------------------------------------------------------------------------------r";for(i=0;i<results.length;i++){varidValue=results[i].selectSingleNode('./accountid').nodeTypedValue;varname=results[i].selectSingleNode('./name').nodeTypedValue;msg+=idValue+"t"+name+"r";}alert(msg);}TheresponsefromtheFetchmethodisaFetchResultelementthatincludesanencodedstring.BeforeyoucanworkwiththeinnertextoftheFetchResultelementasanXMLdocument,youmustunencodethestring.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><FetchResponsexmlns="http://schemas.microsoft.com/crm/2007/WebServices"><FetchResult><resultsetmorerecords="0"paging-cookie="&lt;cookiepage=&quot;1&quot;&gt;&lt;accountidlast=&quot;{D20D96E1-DBE0-DC11-B649-001AA0B84538}&quot;first=&quot;{AE9C2873-FEDF-DC11-98B3-0003FF9EE217}&quot;/&gt;&lt;/cookie&gt;"><result><accountid>{AE9C2873-FEDF-DC11-98B3-0003FF9EE217}</accountid><name>FirstAccountName</name></result><result><accountid>{AF9C2873-FEDF-DC11-98B3-0003FF9EE217}</accountid><name>SecondAccountName</name></result><result><accountid>{0BD4287E-FEDF-DC11-98B3-0003FF9EE217}</accountid><name>ThirdAccountName</name></result</resultset></FetchResult></FetchResponse></soap:Body></soap:Envelope>WhenyouunencodetheinnertextoftheelementsintheFetchResult,thefollowingistheresult:<resultsetmorerecords="0"paging-cookie="&lt;cookiepage=&quot;1&quot;&gt;&lt;accountidlast=&quot;{D20D96E1-DBE0-DC11-B649-001AA0B84538}&quot;first=&quot;{AE9C2873-FEDF-DC11-98B3-0003FF9EE217}&quot;/&gt;&lt;/cookie&gt;"><result><accountid>{AE9C2873-FEDF-DC11-98B3-0003FF9EE217}</accountid><name>FirstAccountName</name></result><result><accountid>{AF9C2873-FEDF-DC11-98B3-0003FF9EE217}</accountid><name>SecondAccountName</name></result><result><accountid>{0BD4287E-FEDF-DC11-98B3-0003FF9EE217}</accountid><name>ThirdAccountName</name></result></resultset>
解决方案三:
获取可用分
解决方案四:
顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶
解决方案五:
学习......