{"id":12426,"date":"2018-07-19T18:06:06","date_gmt":"2018-07-19T12:36:06","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=12426"},"modified":"2018-07-19T18:06:06","modified_gmt":"2018-07-19T12:36:06","slug":"implement-offline-support-for-canvas-app-in-dynamics-365-crm","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2018\/07\/implement-offline-support-for-canvas-app-in-dynamics-365-crm\/","title":{"rendered":"Implement offline support for Canvas App in Dynamics 365 CRM"},"content":{"rendered":"<h2><strong>Introduction:<\/strong><\/h2>\n<p>Recently, we had a requirement where customer wants use Dynamics365 CE using PowerApp in Offline mode<strong>. <\/strong><\/p>\n<h2><strong>Following are the steps to implement offline support for Power App to Dynamics365:<\/strong><\/h2>\n<p style=\"text-align: justify;\"><strong>1<\/strong>. Create a default Canvas app by using Dynamics 365. You can refer to our <a title=\"Create Records in Dynamics 365 with Canvas PowerApp\" href=\"https:\/\/www.inogic.com\/blog\/2018\/07\/create-records-in-dynamics-365-with-canvas-powerapp\/\" target=\"_blank\" rel=\"noopener noreferrer\">previous blog<\/a> here.<\/p>\n<p style=\"text-align: justify;\"><strong>2<\/strong>. Insert a new Screen in the power app and design the page accordingly. This screen we have consider as Home Screen so move this screen to the top as shown in below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-12427\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/07\/Implement-offline-support-for-Canvas-App-in-Dynamics365-CRM.png\" alt=\"Implement offline support for Canvas App in Dynamics365 CRM\" width=\"357\" height=\"243\" \/><\/p>\n<p>We have designed the home screen as shown in below screenshot:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-full wp-image-12428\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/07\/Implement-offline-support-for-Canvas-App-in-Dynamics365-CRM1.png\" alt=\"Implement offline support for Canvas App in Dynamics365 CRM\" width=\"450\" height=\"797\" \/><\/p>\n<p style=\"text-align: justify;\"><strong>3<\/strong>. In Edit screen1, on \u201conselect property\u201d of \u201cIconAccept1\u201d write the formula as:<\/p>\n<p style=\"text-align: justify;\">If(Connection.Connected,<\/p>\n<p style=\"text-align: justify;\">SubmitForm(EditForm1),<\/p>\n<p style=\"text-align: justify;\">Collect(accountstobeCreated,{name: DataCardValue14.Text,address:DataCardValue16.Text,revenue:DataCardValue15.Text,description:DataCardValue13.Text,noofemployee:DataCardValue11.Text} );<\/p>\n<p style=\"text-align: justify;\">SaveData(accountstobeCreated, &#8220;newAccountsInLocalStorage&#8221;));<\/p>\n<p><img decoding=\"async\" class=\"aligncenter  wp-image-12429\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/07\/Implement-offline-support-for-Canvas-App-in-Dynamics365-CRM2.png\" alt=\"Implement offline support for Canvas App in Dynamics365 CRM\" width=\"822\" height=\"298\" \/><\/p>\n<p style=\"text-align: justify;\">The above formula will first check if connection is connected (i.e. if application is connected to internet), if true application will submit the form else create a collection name as \u201caccountstobeCreated\u201d and will store the value of fields.<\/p>\n<p style=\"text-align: justify;\">SaveData function stores the collection in local database under name.<\/p>\n<p style=\"text-align: justify;\"><strong>4<\/strong>. Now back to the home screen, on \u201conselect\u201d property of \u201cnexticon\u201d write the formula as:<\/p>\n<p style=\"text-align: justify;\">If(Connection.Connected,<\/p>\n<p style=\"text-align: justify;\">ClearCollect(AccountCollection, Accounts);<\/p>\n<p style=\"text-align: justify;\">SaveData(AccountCollection,&#8221;AccountInLocalStorage&#8221;),<\/p>\n<p style=\"text-align: justify;\">LoadData(AccountCollection,&#8221;AccountInLocalStorage&#8221;, true));<\/p>\n<p style=\"text-align: justify;\">LoadData(accountstobeCreated,&#8221;newAccountsInLocalStorage&#8221;, true);<\/p>\n<p style=\"text-align: justify;\">Navigate(BrowseScreen1,ScreenTransition.Cover)<\/p>\n<p><img decoding=\"async\" class=\"aligncenter  wp-image-12430\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/07\/Implement-offline-support-for-Canvas-App-in-Dynamics365-CRM3.png\" alt=\"Implement offline support for Canvas App in Dynamics365 CRM\" width=\"819\" height=\"354\" \/><\/p>\n<p style=\"text-align: justify;\">The above formula will first check if connection is connected (i.e. if application is connected to internet), if true application will clear and collect \u201cAccountCollection\u201d which will stores all the records from account entity and later will save the records in \u201cAccountCollection\u201d under the name \u201cAccountInLocalStorage\u201d.<\/p>\n<p style=\"text-align: justify;\">If connection is not available, the application will LoadData from accountCollection and accountstobecreated.<\/p>\n<p style=\"text-align: justify;\">LoadData function re-loads a collection by name that was previously saved with\u00a0<strong>SaveData<\/strong><\/p>\n<p><strong>5. On Item property of BrowseGallery1 write formula as:<\/strong><\/p>\n<p>AccountCollection<\/p>\n<p><img decoding=\"async\" class=\"aligncenter  wp-image-12431\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/07\/Implement-offline-support-for-Canvas-App-in-Dynamics365-CRM4.png\" alt=\"Implement offline support for Canvas App in Dynamics365 CRM\" width=\"825\" height=\"387\" \/><\/p>\n<p style=\"text-align: justify;\"><strong>6<\/strong>. Now Add a Timer Control on BrowseGallery1 and set the following property of Timer:<\/p>\n<p style=\"text-align: justify;\">Auto Start: true<\/p>\n<p style=\"text-align: justify;\">Repeat: true<\/p>\n<p style=\"text-align: justify;\">Duration: 30000<\/p>\n<p style=\"text-align: justify;\"><strong>7<\/strong>. On \u201cOnTimerEnd\u201d property of Timer Control write the formula as:<\/p>\n<p style=\"text-align: justify;\">If(Connection.Connected &amp;&amp;CountRows(accountstobeCreated)&gt;0,<\/p>\n<p style=\"text-align: justify;\">ForAll(accountstobeCreated,Patch(Accounts, Defaults(Accounts),{name:name,description:description}));<\/p>\n<p style=\"text-align: justify;\">Clear(accountstobeCreated);<\/p>\n<p style=\"text-align: justify;\">Refresh(Accounts);<\/p>\n<p style=\"text-align: justify;\">ClearCollect(AccountCollection,Accounts);<\/p>\n<p style=\"text-align: justify;\">SaveData(AccountCollection,&#8221;accountInLocalStorage&#8221;))<\/p>\n<p><img decoding=\"async\" class=\"aligncenter  wp-image-12432\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/07\/Implement-offline-support-for-Canvas-App-in-Dynamics365-CRM5.png\" alt=\"Implement offline support for Canvas App in Dynamics365 CRM\" width=\"827\" height=\"317\" \/><\/p>\n<p style=\"text-align: justify;\">Whenever the timer ends the application will check if internet connection is available and records are present in \u201caccountstobecreated\u201d collection. If true,<\/p>\n<p style=\"text-align: justify;\">Records will be created in CRM using patch function.<\/p>\n<p style=\"text-align: justify;\">\u201caccountstobecreated\u201d collection will be cleared and created records will be saved in \u201cAccountCollection\u201d.<\/p>\n<h2>Conclusion:<\/h2>\n<p>Using simple steps above user can implement offline support for Canvas App in Dynamics365 CRM<\/p>\n<p><a href=\"https:\/\/www.maplytics.com\/features\/maplytics-multi-language-mapping-app-dynamics-365\/\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" class=\"aligncenter  wp-image-11613\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2018\/04\/Generate-Your-Own-New-Leads-Now-Within-Dynamics-365-CRM-with-Maplytics-11.png\" alt=\"Generate Your Own New Leads Now Within Dynamics 365 CRM with Maplytics\" width=\"820\" height=\"205\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: Recently, we had a requirement where customer wants use Dynamics365 CE using PowerApp in Offline mode. Following are the steps to implement offline support for Power App to Dynamics365: 1. Create a default Canvas app by using Dynamics 365. You can refer to our previous blog here. 2. Insert a new Screen in the\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2018\/07\/implement-offline-support-for-canvas-app-in-dynamics-365-crm\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":12441,"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,18,19,38,44],"tags":[244,245,1170],"class_list":["post-12426","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dynamics-365","category-dynamics-365-v9-2","category-dynamics-crm","category-microsoft-powerapps","category-power-apps","tag-canvas-app-in-dynamics365","tag-canvas-app-in-dynamics365-crm","tag-microsoft-powerapps"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/12426","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=12426"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/12426\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/12441"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=12426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=12426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=12426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}