{"id":183,"date":"2009-08-28T08:53:00","date_gmt":"2009-08-28T03:23:00","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=183"},"modified":"2009-08-28T08:53:00","modified_gmt":"2009-08-28T03:23:00","slug":"how-to-convert-a-retrievemultiple-query-written-server-side-to-soap-message-to-be-used-in-javascripts","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2009\/08\/how-to-convert-a-retrievemultiple-query-written-server-side-to-soap-message-to-be-used-in-javascripts\/","title":{"rendered":"How to convert a RetrieveMultiple query written Server side to SOAP message to be used in Javascripts"},"content":{"rendered":"<div align=\"justify\"><\/div>\n<p align=\"justify\">It has often been seen that a RetrieveMultiple query that is very easy to write using the server side Query Expression objects using CRM webservices becomes difficult to achieve if we need to create a SOAP message for the same.<\/p>\n<p>In this article we hope to explain each of the elements involved in the writing of SOAP messages to be used through Javascripts.<br \/>\nLet us take a simple RetrieveMultiple code as an example.<br \/>\nWhile writing the SOAP message the first component required is the SOAP envelope. This is the same at all times for all SOAP messages.<br \/>\n&#8220;<!--?xml version='1.0' encoding='utf-8'?-->&#8220;+<br \/>\n&#8220;&#8221; xmlns:xsi=&#8217;http:\/\/www.w3.org\/2001\/XMLSchema-instance'&#8221;+<br \/>\n&#8221; xmlns:xsd=&#8217;http:\/\/www.w3.org\/2001\/XMLSchema&#8217;&gt;&#8221;+<br \/>\nNext we need to add the Authentication Header that needs to be passed along with the SOAP message for successful authentication with the CRM Web service. CRM has an inbuilt function GenerateAuthenticationHeader() that can be used for this purpose.<br \/>\nvar authenticationHeader = GenerateAuthenticationHeader();<br \/>\nSOAP Body is where the actual SDK message to be executed is included.<br \/>\n&#8220;&#8221;+<br \/>\nIn our example we are using the RetrieveMultiple Message so we provide the Message name and the schema reference to the CRM webservices<br \/>\n&#8220;&#8221;+<br \/>\nThe parameter to a Retrieve Multiple Message is always a query expression<br \/>\nQueryExpression query = new QueryExpression();<br \/>\n&#8220;&#8221; xsi:type=&#8217;q1:QueryExpression&#8217;&gt;&#8221;+<br \/>\nNow include all properties of the Query object that you set.<br \/>\n<strong>Entity name<br \/>\n<\/strong><br \/>\nquery.EntityName = EntityName.incident.ToString();<br \/>\n&#8220;incident&#8221;+<br \/>\n<strong>Column Set<\/strong><\/p>\n<p align=\"justify\">query.ColumnSet = new AllColumns();<\/p>\n<p>&#8220;&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;title&#8221;+<br \/>\n&#8220;incidentid&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n<strong>Criteria<br \/>\n<\/strong><br \/>\nConditionExpression condition = new ConditionExpression();<br \/>\ncondition.AttributeName = &#8220;title&#8221;;<br \/>\ncondition.Operator = ConditionOperator.Like;<br \/>\ncondition.Values = new string [] {strSearchText};<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;And&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;title&#8221;+<br \/>\n&#8220;Like&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;&#8221;+searchtext +&#8221;&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\n&#8220;&#8221;+<br \/>\nHere, we have used &#8216;Like&#8217; condition operator, likewise one can use any of the sdk supported operators and change the values to be matched accordingly.<\/p>\n<p align=\"justify\"><strong>Order by<br \/>\n<\/strong><\/p>\n<p>&nbsp;<br \/>\n<strong><br \/>\n<\/strong>OrderExpression oe = new OrderExpression();<br \/>\noe.AttributeName = &#8220;title&#8221;;<br \/>\noe.OrderType = OrderType.Ascending;<br \/>\nquery.Orders = new OrderExpression[]{oe};<br \/>\n&#8220;&#8221; +<br \/>\n&#8220;&#8221; +<br \/>\n&#8220;title&#8221; +<br \/>\n&#8220;Ascending&#8221; +<br \/>\n&#8220;&#8221; +<br \/>\n&#8220;&#8221; +<br \/>\nOnce you have set all of these\u2026 your SOAP message is ready for execution.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It has often been seen that a RetrieveMultiple query that is very easy to write using the server side Query Expression objects using CRM webservices becomes difficult to achieve if we need to create a SOAP message for the same. In this article we hope to explain each of the elements involved in the writing\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2009\/08\/how-to-convert-a-retrievemultiple-query-written-server-side-to-soap-message-to-be-used-in-javascripts\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[19,33],"tags":[315,1284,1473],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-dynamics-crm","category-javascript","tag-conditionoperator","tag-orderexpression","tag-retrievemultiple"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}