{"id":20961,"date":"2019-10-31T12:21:58","date_gmt":"2019-10-31T12:21:58","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=20961"},"modified":"2022-07-01T12:57:24","modified_gmt":"2022-07-01T07:27:24","slug":"how-to-get-paging-cookie-while-retrieving-data-using-fetch-xml-query-in-microsoft-flow","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2019\/10\/how-to-get-paging-cookie-while-retrieving-data-using-fetch-xml-query-in-microsoft-flow\/","title":{"rendered":"How to get Paging Cookie while retrieving data using Fetch XML Query in Microsoft Flow"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Microsoft Flow is bringing new connectors day by day to ease the life of its users.<\/p>\n<p style=\"text-align: justify;\">With the new connector for Common Data Service, while performing the List Records action, now we have the provision to use <strong>Select Query<\/strong>, <strong>Fetch XML Query<\/strong> and <strong>Skip token,<\/strong> rest of the other things remaining the same.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20962\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"961\" height=\"558\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/Microsoft-Flow.png 601w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/Microsoft-Flow-300x174.png 300w\" sizes=\"(max-width: 961px) 100vw, 961px\" \/><\/p>\n<p>Today, we\u2019ll see how we can use Fetch Xml Query and then get the paging cooking to re-use it for next retrieve request.<\/p>\n<p>Consider a scenario where I have an on demand flow which is called by passing the paging cookie, page number and count as parameters.<\/p>\n<p>Based on the parameters passed, the retrieval takes place and also the necessary actions are performed on the retrieved records. After the retrieval, if there are more records, then the flow returns back the paging cookie for next retrieval.<\/p>\n<p>Let\u2019s take a look at how to design a Microsoft Flow for this request.<\/p>\n<p><strong>Step 1:<\/strong><\/p>\n<p>Select an HTTP Request Trigger.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20963\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/1Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"908\" height=\"546\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/1Microsoft-Flow.png 599w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/1Microsoft-Flow-300x180.png 300w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><\/p>\n<p>Given below is the JSON Schema as per the requirement.<\/p>\n<pre class=\"lang:default decode:true \">{\r\n\r\n\"type\": \"object\",\r\n\r\n\"properties\": {\r\n\r\n\"paging-cookie\": {\r\n\r\n\"type\": \"string\"\r\n\r\n},\r\n\r\n\"page\": {\r\n\r\n\"type\": \"string\"\r\n\r\n},\r\n\r\n\"count\": {\r\n\r\n\"type\": \"string\"\r\n\r\n}\r\n\r\n}\r\n\r\n}<\/pre>\n<p><strong>Step 2: <\/strong><\/p>\n<p>Initialize the paging cookie. This is the paging cookie sent as a parameter in the http request.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20964\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/2Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"859\" height=\"229\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/2Microsoft-Flow.png 600w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/2Microsoft-Flow-300x80.png 300w\" sizes=\"(max-width: 859px) 100vw, 859px\" \/><\/p>\n<p>Value expression,<\/p>\n<blockquote><p><code>if(empty(triggerBody()?['paging-cookie']),'',concat('paging-cookie=',triggerBody()?['paging-cookie'],''))<\/code><\/p><\/blockquote>\n<blockquote><p><strong><em>Note:<\/em><\/strong><em> The above Value expression makes sure that we handle the empty paging cookie scenario as well.<\/em><\/p><\/blockquote>\n<p><strong>Step 3:<\/strong><\/p>\n<p>Retrieve the records using Fetch XML.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20965\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/3Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"840\" height=\"862\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/3Microsoft-Flow.png 605w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/3Microsoft-Flow-292x300.png 292w\" sizes=\"(max-width: 840px) 100vw, 840px\" \/><\/p>\n<p>Here,<\/p>\n<p>count \u2013 It is sent over as a parameter in the http request.<\/p>\n<p>page \u2013 It is sent over as a parameter in the http request.<\/p>\n<p>pagingCookie \u2013 This is the variable initialized in Step 2.<\/p>\n<p><strong>Step 4:<\/strong><\/p>\n<p>Perform necessary actions on the records retrieved in Step 3.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20966\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/4Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"873\" height=\"68\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/4Microsoft-Flow.png 603w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/4Microsoft-Flow-300x23.png 300w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><\/p>\n<p><strong>Step 5:<\/strong><\/p>\n<p>Parse the JSON of the response from Step 3. This helps us get the paging cookie.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20967\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/5Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"858\" height=\"467\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/5Microsoft-Flow.png 601w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/5Microsoft-Flow-300x163.png 300w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/p>\n<p>For copying purpose, I am pasting here the JSON.<\/p>\n<pre class=\"lang:default decode:true \">{\r\n\r\n\"type\": \"object\",\r\n\r\n\"properties\": {\r\n\r\n\"@@Microsoft.Dynamics.CRM.fetchxmlpagingcookie\": {\r\n\r\n\"type\": \"string\"\r\n\r\n}\r\n\r\n}\r\n\r\n}<\/pre>\n<p><strong>Step 6:<\/strong><\/p>\n<p>Return back the paging cookie to where the request was originated.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20968\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/6Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"852\" height=\"379\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/6Microsoft-Flow.png 600w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/6Microsoft-Flow-300x134.png 300w\" sizes=\"(max-width: 852px) 100vw, 852px\" \/><\/p>\n<p>The dynamic parameter used in the above body is a by-product of Step 5.<\/p>\n<p><strong><em>Note:<\/em><\/strong><\/p>\n<p><em>Out of the box Pagination brings the data in the multiple of 512, so if you have specific pagination needs, then using paging cookie makes more sense.<\/em><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20969\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/7Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"845\" height=\"269\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/7Microsoft-Flow.png 600w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/7Microsoft-Flow-300x96.png 300w\" sizes=\"(max-width: 845px) 100vw, 845px\" \/><\/p>\n<p><strong>Flow in its entirety:<\/strong><\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-20970\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/8Microsoft-Flow.png\" alt=\"Microsoft Flow\" width=\"926\" height=\"732\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/8Microsoft-Flow.png 611w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/8Microsoft-Flow-300x237.png 300w\" sizes=\"(max-width: 926px) 100vw, 926px\" \/><\/p>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Now, using Microsoft Flow, we can also handle paging of the records as per the requirement.<\/p>\n<p><a href=\"https:\/\/www.inogic.com\/product\/development\/microsoft-flow-logic-apps-dynamics-365\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter wp-image-20972\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/PowerApps-1-1.png\" alt=\"\" width=\"816\" height=\"204\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/PowerApps-1-1.png 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/PowerApps-1-1-300x75.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/PowerApps-1-1-768x192.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2019\/10\/PowerApps-1-1-660x165.png 660w\" sizes=\"(max-width: 816px) 100vw, 816px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Microsoft Flow is bringing new connectors day by day to ease the life of its users. With the new connector for Common Data Service, while performing the List Records action, now we have the provision to use Select Query, Fetch XML Query and Skip token, rest of the other things remaining the same. Today,\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2019\/10\/how-to-get-paging-cookie-while-retrieving-data-using-fetch-xml-query-in-microsoft-flow\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":20973,"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":[16,36,1985],"tags":[792,1150],"class_list":["post-20961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-microsoft-flow","category-power-automate","tag-fetch-xml","tag-microsoft-flow"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/20961","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=20961"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/20961\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/20973"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=20961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=20961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=20961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}