{"id":4472,"date":"2023-03-16T05:16:15","date_gmt":"2023-03-16T05:16:15","guid":{"rendered":"https:\/\/himbap.com\/blog\/?p=4472"},"modified":"2023-03-16T05:16:15","modified_gmt":"2023-03-16T05:16:15","slug":"fetching-incremental-data-from-navision-for-d365-ce","status":"publish","type":"post","link":"https:\/\/himbap.com\/blog\/?p=4472","title":{"rendered":"Fetching incremental data from Navision for D365 CE"},"content":{"rendered":"<p><strong>Requirement<\/strong><br \/>\nLet&#8217;s say we want to fetch incremental data from BC for CRM using Kingswaysoft.<\/p>\n<p><strong>Details<\/strong><br \/>\nWhile working with CRM and BC integration using Kingswaysoft, let&#8217;s say we want to get incremental data from Navision, for example records modified in last 2 minutes or so. In that case we need to have a datetime field in the NAV table which we want to retrieve. When we have datetime field in nav its data type is <strong>datetimeoffset(7)<\/strong> so while we want to set this dates we need to make similarly format to fetch data.<\/p>\n<p>So first we need to declare two <strong>string variable<\/strong> which we will be using to store dates specific to nav datetime format. let say we create<br \/>\n1. LastRun &#8211; To store last integration run details<br \/>\n2. CurrentRun &#8211; To store current integration run details<\/p>\n<p>Based on this variables we will fetch data which is modified between these two datetime. Now using expression (We are using Premium Derived Column) we need to setup date like below<\/p>\n<p>CurrentRun should be setup like below<\/p>\n<p>WriteValueToVariable(@[User::CurrentRun], (DT_STR,4,1252)DATEPART( &#8220;dd&#8221; , getdate() )+ &#8220;-&#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;mm&#8221; , getdate() ), 2) + &#8220;-&#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;yy&#8221; , getdate() ), 2) + &#8221; &#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;Hh&#8221; , getdate() ), 2) + &#8220;:&#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;mi&#8221; , getdate() ), 2))<\/p>\n<p>LastRun should be setup like below<\/p>\n<p>WriteValueToVariable(@[User::LastRun],(DT_STR,4,1252)DATEPART( &#8220;dd&#8221; , getdate() )+ &#8220;-&#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;mm&#8221; , getdate() ), 2) + &#8220;-&#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;yy&#8221; , getdate() ), 2) + &#8221; &#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;Hh&#8221; , getdate() ), 2) + &#8220;:&#8221;<br \/>\n+ RIGHT(&#8220;0&#8221; + (DT_STR,4,1252)DATEPART( &#8220;mi&#8221; , dateadd(&#8220;mi&#8221;,-02,getdate()) ), 2))<\/p>\n<p>In above example I am taking 2 min gap to fetch data. Now under NAV source editor we can add query like below to fetch our table<\/p>\n<p><a href=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2023\/03\/navintegration.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-4473 aligncenter\" src=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2023\/03\/navintegration-300x63.jpg\" alt=\"navintegration\" width=\"300\" height=\"63\" srcset=\"https:\/\/himbap.com\/blog\/wp-content\/uploads\/2023\/03\/navintegration-300x63.jpg 300w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2023\/03\/navintegration-624x132.jpg 624w, https:\/\/himbap.com\/blog\/wp-content\/uploads\/2023\/03\/navintegration.jpg 1002w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p><strong>Summary<\/strong><br \/>\nThis is how we can fetch incremental data from Navision suing datetime.<\/p>\n<p>Hope it will help someone !!<br \/>\n<strong>Keep learning and Keep Sharing !!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Requirement Let&#8217;s say we want to fetch incremental data from BC for CRM using Kingswaysoft. Details While working with CRM and BC integration using Kingswaysoft, let&#8217;s say we want to get incremental data from Navision, for example records modified in last 2 minutes or so. In that case we need to have a datetime field in the NAV table which&#8230; <a href=\"https:\/\/himbap.com\/blog\/?p=4472\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[847,402,522,882,883],"tags":[1031,1033,1032,943],"_links":{"self":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4472"}],"collection":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4472"}],"version-history":[{"count":1,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4472\/revisions"}],"predecessor-version":[{"id":4474,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/4472\/revisions\/4474"}],"wp:attachment":[{"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/himbap.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}