{"id":34172,"date":"2023-03-07T17:07:19","date_gmt":"2023-03-07T11:37:19","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=34172"},"modified":"2023-03-10T10:03:18","modified_gmt":"2023-03-10T04:33:18","slug":"how-to-use-autocomplete-of-dataverse-search-in-canvas-app","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2023\/03\/how-to-use-autocomplete-of-dataverse-search-in-canvas-app\/","title":{"rendered":"How to use Autocomplete of Dataverse Search in Canvas App?"},"content":{"rendered":"<p>Recently, I was working on a requirement in the Canvas app regarding autocomplete. We wanted to display the auto-complete suggestion based on the account names as they were typed in. After fiddling around with the requirement, I stumbled upon the <a href=\"https:\/\/learn.microsoft.com\/en-us\/power-apps\/developer\/data-platform\/webapi\/relevance-search\" target=\"_blank\" rel=\"noopener\">Dataverse Search<\/a>. Microsoft recently came out with Dataverse Search API, which consists of various search features, and autocomplete is a part of it. Let\u2019s dive in and see how to use that in a Canvas app.<\/p>\n<p>So, for a basic setup, I\u2019ve taken one text input and one label control. On change of the text input, I will call a Power Automate Flow, which will return the autocomplete response.<\/p>\n<p><strong>Power Automate Flow &#8211;<\/strong><\/p>\n<p>In the power automate flow, I\u2019m calling the autocomplete API shown below \u2013<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-34178\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/1Canvas-App-1.jpeg\" alt=\"Canvas App\" width=\"844\" height=\"752\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/1Canvas-App-1.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/1Canvas-App-1-300x267.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/1Canvas-App-1-660x588.jpeg 660w\" sizes=\"(max-width: 844px) 100vw, 844px\" \/><\/p>\n<p>The API of autocomplete goes like <strong><em>{crmURL}\/api\/search\/v1.0\/autocomplete<\/em><\/strong> and in the body of the request, we need to pass the search term, which I\u2019m passing from the Canvas app and restrict the autocomplete to only account entity. After getting the response from the API, we need to parse the response, which is in JSON form, as shown below \u2013<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-34177\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/2Canvas-App-1.jpeg\" alt=\"Canvas App\" width=\"838\" height=\"480\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/2Canvas-App-1.jpeg 766w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/2Canvas-App-1-300x172.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/2Canvas-App-1-660x378.jpeg 660w\" sizes=\"(max-width: 838px) 100vw, 838px\" \/><\/p>\n<p>After parsing the response, I\u2019m storing the value after removing the {crmhit} &amp; {\/crmhit} that is returned in the response. So, for that, we will use replace function provided in Power Automate Flow as shown below \u2013<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-34176\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/3Canvas-App-1.jpeg\" alt=\"Canvas App\" width=\"869\" height=\"289\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/3Canvas-App-1.jpeg 785w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/3Canvas-App-1-300x100.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/3Canvas-App-1-768x255.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/3Canvas-App-1-660x219.jpeg 660w\" sizes=\"(max-width: 869px) 100vw, 869px\" \/><\/p>\n<p>After storing the autocomplete response in a variable, I\u2019m simply returning it to the Canvas app like below \u2013<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-34175\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/4Canvas-App-1.jpeg\" alt=\"Canvas App\" width=\"878\" height=\"300\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/4Canvas-App-1.jpeg 776w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/4Canvas-App-1-300x102.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/4Canvas-App-1-768x262.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/4Canvas-App-1-660x225.jpeg 660w\" sizes=\"(max-width: 878px) 100vw, 878px\" \/><\/p>\n<p>This is it for the Power Automate Flow; now we will see the Canvas app.<\/p>\n<p>In the Canvas app, I\u2019ve added a text input control. On change of the same, I\u2019m calling the Power Automate Flow that we created before and storing the response passed from flow in a variable like below \u2013<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-34174\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/5Canvas-App-1.jpeg\" alt=\"Canvas App\" width=\"1256\" height=\"50\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/5Canvas-App-1.jpeg 1256w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/5Canvas-App-1-300x12.jpeg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/5Canvas-App-1-1024x41.jpeg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/5Canvas-App-1-768x31.jpeg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/5Canvas-App-1-660x26.jpeg 660w\" sizes=\"(max-width: 1256px) 100vw, 1256px\" \/><\/p>\n<p>And in the Text property of label control, I\u2019m showing the variable that we\u2019ve stored.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-34173\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/6Canvas-App-1.jpeg\" alt=\"Canvas App\" width=\"967\" height=\"99\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/6Canvas-App-1.jpeg 635w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/6Canvas-App-1-300x31.jpeg 300w\" sizes=\"(max-width: 967px) 100vw, 967px\" \/><\/p>\n<p>So, after everything is set up, let\u2019s see the autocomplete in action.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-34179\" style=\"border: 1px solid #0a0a0a; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/03\/Autocomplete.gif\" alt=\"\" width=\"1066\" height=\"819\" \/><\/p>\n<p><strong>Conclusion<\/strong><\/p>\n<p>This is how we can use autocomplete feature in the Canvas app.<\/p>\n<h3><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:13px;margin-bottom:20px\"><div class=\"su-heading-inner\">Want to visualize, design, and build a business app from a <a href=\"https:\/\/www.inogic.com\/services\/microsoft-power-platform\/microsoft-power-apps-canvas-app\/\" target=\"_blank\" rel=\"noopener\">canvas in Microsoft Power Apps<\/a>?<\/div><\/div><\/h3>\n<p><em>Wish to do it without writing code in a traditional programming language?<br \/>\nContact us at <a href=\"mailto:crm@inogic.com\" target=\"_blank\" rel=\"noopener\">crm@inogic.com<\/a> and our Microsoft Dynamics 365 and Power Platform Inogic- Professional Services Division will help you achieve it effortlessly!\u201d<br \/>\n<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I was working on a requirement in the Canvas app regarding autocomplete. We wanted to display the auto-complete suggestion based on the account names as they were typed in. After fiddling around with the requirement, I stumbled upon the Dataverse Search. Microsoft recently came out with Dataverse Search API, which consists of various search\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2023\/03\/how-to-use-autocomplete-of-dataverse-search-in-canvas-app\/\">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":[1954],"tags":[1867],"class_list":["post-34172","post","type-post","status-publish","format-standard","hentry","category-canvas-apps","tag-canvas-app"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/34172","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=34172"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/34172\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=34172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=34172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=34172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}