{"id":33812,"date":"2022-01-19T07:16:58","date_gmt":"2022-01-19T12:16:58","guid":{"rendered":"https:\/\/centricconsulting.com\/?p=33812"},"modified":"2022-01-18T13:26:51","modified_gmt":"2022-01-18T18:26:51","slug":"creating-a-unified-dataverse-search-experience-in-canvas-apps","status":"publish","type":"post","link":"https:\/\/centricconsulting.com\/blog\/creating-a-unified-dataverse-search-experience-in-canvas-apps\/","title":{"rendered":"Creating a Unified Dataverse Search Experience in Canvas Apps"},"content":{"rendered":"
Recently, I had a client interested in building a Power App<\/a> Canvas app for mobile devices that would take some of the more routine aspects of their Dynamics<\/a> sales process and provide their salespeople with an easier way to do some of the tasks associated with capturing customer information.<\/p>\n However, this particular client\u2019s users didn\u2019t like using Dynamics, and they wanted to streamline this process for them without needing to use the Dynamics mobile app. Canvas apps to the rescue!<\/p>\n When I started this project, I admittedly didn\u2019t have a deep knowledge of Dynamics. As a part of the app, the client wanted a single search interface whereby users could search across Contacts, Accounts, Leads and Opportunities, and have those presented in one pane of glass. My immediate thought was to simply use an input control and a gallery to display the results, but with Galleries, they really want a single data schema and data source in order to display information.<\/strong><\/p>\n With these tables, the data schema was decidedly different across each of them. After doing some digging, I realized my best option was to use the Dataverse Search (formally Dynamics Relevance) API<\/a>. With this being my first real exposure to that API, I immediately went to see if anybody else has ever done this type of work before, and I came across this blog<\/a>.<\/p>\n This particular solution relied on using a Canvas app and then calling a Power Automate<\/a> flow to retrieve the results from the Dataverse Search API. While it certainly performed the job, what I also found was the lag between clicking the button in the Canvas and the Power Automate returning results would be unacceptable for my client. So, I figured, why not just let Power Apps query it directly?<\/p>\n My first step into understanding how to query the Search API and return the results I needed was to read the documentation out on Microsoft\u2019s site<\/a>. This information provided me with the necessary syntax to query the API with a POST command. From here, I knew I wanted to test it to make sure I could get results returned.<\/strong><\/p>\n This is where Postman comes into play. Microsoft also provides a tutorial<\/a> on how to connect to the Dataverse Search API using Postman, especially around authenticating to service, which I found invaluable. By following that tutorial, you\u2019ll be ready to try out a simple query.<\/p>\n In my case, I had some test data with my name in Dynamics, so I did a search on it. If everything is working properly, you should see a response like the one below:<\/p>\n <\/a><\/p>\n \u00a0{<\/strong><\/p>\n \u00a0\u00a0\u00a0 \u201csearch\u201d: \u201cJo Karnes\u201d<\/strong><\/p>\n }<\/strong><\/p>\n In that search, I simply tested it with a search term query, in this case \u201cJo Karnes\u201d. This particular search would scan across all of the Dynamics tables I configured to search through Dataverse Search (see here for instructions<\/a> on how to configure tables for this), but the requirement for this app was to only return results across four specific tables. We need to specify those tables in the Body of our request. We can do that by defining those entities as shown below:<\/strong><\/p>\nOne Search to Rule Them All \u2013 Using Dataverse Search<\/h2>\n
Please Mr. Postman<\/h2>\n