MSCrm javascript queryByAttribute

 我自已实现的

function  getq1AttributesString(attributes)
{
   
   
var  strRet = "" ;
   
for (i = 0 ;i < attributes.length;i ++ )
  {
    strRet
+= ( " <q1:Attribute> " + attributes[i] + " </q1:Attribute> " ) ;

    
  }
   
return  strRet;
}

function  getq1AttributesValue(attributes)
{
   
   
var  strRet = "" ;
   
for (i = 0 ;i < attributes.length;i ++ )
  {
    strRet
+= ( " <q1:Value xsi:type=\ " xsd:string\ " > " + attributes[i] + " </q1:Value> " );

    
  }
   
return  strRet;
}

function  queryByAttribute(entityName, columnsetAttributes, queryAttributes, queryAttributesValue)
{
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> "   +  
"     <RetrieveMultiple xmlns=\ " http: // schemas.microsoft.com/crm/2007/WebServices\">" + 
"       <query xmlns:q1=\ " http: // schemas.microsoft.com/crm/2006/Query\" xsi:type=\"q1:QueryByAttribute\">" + 
"         <q1:EntityName> " + entityName + " </q1:EntityName> "   +  
"         <q1:ColumnSet xsi:type=\ " q1:ColumnSet\ " > "   +  
"           <q1:Attributes> "   +  getq1AttributesString(columnsetAttributes) +  
"           </q1:Attributes> "   +  
"         </q1:ColumnSet> "   +  
"         <q1:Attributes> "   +  getq1AttributesString(queryAttributes) +  
"         </q1:Attributes> "   +  
"         <q1:Values> "   +  getq1AttributesValue(queryAttributesValue)  +  
"         </q1:Values> "   +  
"       </query> "   +  
"     </RetrieveMultiple> "   +  
"   </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/RetrieveMultiple " );
xmlHttpRequest.setRequestHeader(
" Content-Type " " text/xml; charset=utf-8 " );
xmlHttpRequest.setRequestHeader(
" Content-Length " , xml.length);
xmlHttpRequest.send(xml);

var  resultXml  =  xmlHttpRequest.responseXML;
return  resultXml;
}
var  queryAttributes = new  Array( " pricelevelid " , " productid " , " uomid " );
var  columnsetAttributes = new  Array( " amount " );
var  queryAttributesValue = new  Array( " 02BC5E52-021D-DE11-9A15-000AE42C41EE " , " 75E1AB61-27DE-DD11-9A12-000AE42C41EE " , " A1278C3F-BBDB-DD11-AB5E-002215572EEF " );



queryByAttribute(
" productpricelevel " ,columnsetAttributes,queryAttributes,queryAttributesValue);

 

 

 

转载于:https://www.cnblogs.com/janmson/archive/2009/04/13/1434746.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值