Crm4.0 multi-object association query

Source: Internet
Author: User

C # code implementation:

  LinkEntity link = new LinkEntity();            link.LinkFromEntityName = "new_ddxy";            link.LinkFromAttributeName = "new_salesorder";            link.LinkToEntityName = "salesorder";            link.LinkToAttributeName = "salesorderid";            ConditionExpression cond = new ConditionExpression();            cond.AttributeName = "ordernumber";            cond.Operator = ConditionOperator.Equal;            cond.Values = new string[] { "ORD-04412-708MJ0" };            FilterExpression filter = new FilterExpression();            filter.Conditions = new ConditionExpression[] { cond };            filter.FilterOperator = LogicalOperator.And;            link.JoinOperator = JoinOperator.Inner;            link.LinkCriteria = filter;            LinkEntity link2 = new LinkEntity();            link2.LinkFromEntityName = "new_ddxy";            link2.LinkFromAttributeName = "new_productpricelevel_kz";            link2.LinkToEntityName = "new_productpricelevel_kz";            link2.LinkToAttributeName = "new_productpricelevel_kzid";            ConditionExpression cond2 = new ConditionExpression();            cond2.AttributeName = "new_sftb";            cond2.Operator = ConditionOperator.Equal;            cond2.Values = new object[] { true };            link2.JoinOperator = JoinOperator.Inner;            FilterExpression filter2 = new FilterExpression();            filter2.FilterOperator = LogicalOperator.And;            filter2.Conditions = new ConditionExpression[] { cond2 };            link2.LinkCriteria = filter2;            QueryExpression query = new QueryExpression();            query.EntityName = "new_ddxy";            query.ColumnSet = new AllColumns();            query.LinkEntities = new LinkEntity[] { link, link2 };            BusinessEntityCollection entities = (BusinessEntityCollection)service.RetrieveMultiple(query);            
**************** * Var xml = "" + "<? XML version = \ "1.0 \" encoding = \ "UTF-8 \"?> "+" <Soap: envelope xmlns: Soap = \ "external" xmlns: xsi = \ "external" xmlns: XSD = \ "http://www.w3.org/2001/xmlschema\"> "+" <soap: header> "+" <crmauthenticationtoken xmlns = \ "success"> "+" <authenticationtype xmlns = \ "success"> 0 </authenticationtype> "+" <Organizationname xmlns = \ "canonical"> szyq </organizationname> "+" <callerid xmlns = \ "canonical"> 00000000-0000-0000-0000-000000000000 </callerid>" + "</crmauthenticationtoken>" + "</soap: header> "+" <soap: Body> "+" <retrievemultiple xmlns = \ "http://schemas.microsoft.com/crm/2007/webservices\"> "+" <query xmlns: Q1 = \ "HTTP: // Schemas.microsoft.com/crm/2006/query\ "xsi: TYPE = \" Q1: queryexpression \ ">" + "<Q1: entityname> new_ddxy </Q1: entityname>" + "<Q1: columnset xsi: TYPE = \ "Q1: allcolumns \"/> "+" <Q1: distinct> false </Q1: distinct> "+" <Q1: linkentities> "+" <Q1: linkentity> "+" <Q1: linkfromattributename> new_salesorder </Q1: linkfromattributename> "+" <Q1: linkfromentityname> new_ddxy </Q1: linkfromentityname> "+" <Q1: linkto Entityname> salesorder </Q1: linktoentityname> "+" <Q1: linktoattributename> salesorderid </Q1: linktoattributename> "+" <Q1: joinoperator> Inner </Q1: joinoperator> "+" <Q1: linkcriteria> "+" <Q1: filteroperator> and </Q1: filteroperator> "+" <Q1: conditions> "+" <Q1: condition> "+" <Q1: attributename> ordernumber </Q1: attributename> "+" <Q1: Operator> equal </Q1: Operator> "+" <Q1: values> "+" <Q1: Value xsi: typ E = \ "XSD: String \"> ORD-04412-708MJ0 </Q1: value> "+" </Q1: values> "+" </Q1: condition> "+" </Q1: conditions> "+" </Q1: linkcriteria> "+" </Q1: linkentity> "+" <Q1: linkentity> "+" <Q1: linkfromattributename> plaintext </Q1: linkfromattributename> "+" <Q1: linkfromentityname> new_ddxy </Q1: linkfromentityname> "+" <Q1: linktoentityname> new_productpricelevel_kz </Q1: linktoentityname> "+" <Q1: l Inktoattributename> new_productpricelevel_kzid </Q1: linktoattributename> "+" <Q1: joinoperator> Inner </Q1: joinoperator> "+" <Q1: linkcriteria> "+" <Q1: filteroperator> and </Q1: filteroperator> "+" <Q1: conditions> "+" <Q1: Condition> "+" <Q1: attributename> new_sftb </Q1: attributename> "+" <Q1: Operator> equal </Q1: Operator> "+" <Q1: values> "+" <Q1: Value xsi: TYPE = \ "XSD: boolean \ "> true </Q1: value>" + "</Q1: Values> "+" </Q1: Condition> "+" </Q1: conditions> "+" </Q1: linkcriteria> "+" </Q1: linkentity> "+" </Q1: linkentities> "+" </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.mi Crosoft.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; alert (resultxml. XML ); // ********************** return results *************** * ** <? 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: body> <strong xmlns = "http://schemas.microsoft.com/crm/2007/WebServices"> <retrievemultipleresult entityname = "new_ddxy" morerecords = "0" pagingcookie = ""> <businessentitities xmlns = "http://schemas.microsoft.com/crm/2006/WebServices"> <businessentitity xmlns: q1 = "http://schemas.microsoft.com/crm/2007/WebServices" xsi: TYPE = "Q1: new_ddxy"> <Q1: statecode formattedvalue = "available"> active </Q1: statecode> <Q1: new_cklsxx name = "no"> 0 </Q1: new_cklsxx> <Q1: new_productpricelevel_kz name = "online declaration (one year)" DSC = "0"> {proof} </Q1: new_productpricelevel_kz> <Q1: createdon date = "2010-7-27" time = "14:56"> 2010-07-27t14: 56: 59 + 08: 00 </Q1: createdon> <Q1: new_yxbz name = "no"> 0 </Q1: new_yxbz> <Q1: new_tbyxq name = "no"> 0 </Q1: new_tbyxq> <Q1: new_yxqz date = "2010-7-13" time = "0:00"> 2010-07-13t00: 00: 00 + 08: 00 </Q1: new_yxqz> <Q1: new_ddxyid> {CCC8A526-4C99-DF11-9F44-000C29C44AE5} </Q1: new_ddxyid> <Q1: new_yxqq date = "2010-7-21" time = "0:00"> 2010-07-21t00: 00: 00 + 08: 00 </Q1: new_yxqq> <Q1: ownerid name = "CRM system customizer" DSC = "0" type = "systemuser"> {35f91b00-7b64-df11-beb9-000c29692715} </Q1: ownerid> <Q1: modifiedon date = "2010-7-27" time = "16:35"> 2010-07-27t16: 35: 59 + 08: 00 </Q1: modifiedon> <Q1: statuscode name = "available"> 1 </Q1: statuscode> <Q1: new_name> 2101140020.1866450l </Q1: new_name> <Q1: timezoneruleversionnumber formattedvalue = "0"> 0 </Q1: timezoneruleversionnumber> <Q1: modifiedby DSC = "0" name = "system"> {AD97F2C4-DDD5-41B2-8D59-359ED8DE1598} </Q1: modifiedby> <Q1: owningbusinessunit> {A02CA4E9-315B-DF11-9A5A-000C29692715} </Q1: owningbusinessunit> <Q1: new_fwbh> 90000000000001265744 </Q1: new_fwbh> <Q1: new_sfqetk name = "no"> 0 </Q1: new_sfqetk> <Q1: createdby name = "system" DSC = "0" >{ AD97F2C4-DDD5-41B2-8D59-359ED8DE1598} </Q1: createdby> <Q1: new_salesorder name = "Chen Gang" DSC = "0"> {8c9c6320-4c99-df11-9f44-000c29c44ae5} </Q1: new_salesorder> <Q1: new_sftb name = "no"> 0 </Q1: new_sftb> </businesstity> </businesstities> </retrievemultipleresult> </entity> </soap: Body> </soap: envelope>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.