SQL Stored Procedures to PowerApps

  • SQL Stored Procedures to PowerApps

    Posted by DSC Communities on April 16, 2020 at 5:00 pm
    • Andy Tippin

      Member

      April 16, 2020 at 5:00 PM

      I’m trying to pull in SQL data to a PowerApp but my SQL data is the output from a stored procedure.
      It sounds like I need to use a Flow in conjunction with PowerApps to accomplish this.Ā 
      I’ve got my on-prem SQL setup on a data gateway and that’s working fine.Ā 
      I can create my flow ok: Triggered by PowerApps button, set static params just for testing. But the output options are very limited.Ā 
      Using the “Respond to PowerApp” step, the only option I have in dynamic content is the Return Code. Which, by the way, comes back as an empty string.
      So I get no visible output in my app. I can check the flow status and see the output but there’s nothing useful in there.

      I’ve tested the sproc in SSMS with the same creds and it works fine. Returns 179 records.

      Any ideas?

      ——————————
      Andy Tippin
      ——————————

    • Will Page

      Member

      April 17, 2020 at 3:34 AM

      You can return complex data back to PowerApps with this method: https://powerapps.microsoft.com/en-us/blog/return-an-array-from-flow-to-powerapps-response-method/

      ——————————
      Will Page
      Technical consultant
      Christchurch, NZ
      ——————————
      ——————————————-

    • Andy Tippin

      Member

      April 17, 2020 at 1:15 PM

      I was followĀ This linkĀ to do the stored procedures.
      I tried the method you said and tried just running a SQL query with the Execute statement to run the sproc. I got some error stating it’s not supported through the on-prem gateway.

      I did run acrossĀ thisĀ which might suggest that, even though I don’t see the data in the response, it may be present.Ā 

      You should be able to get the procedure results with the following expression under Microsoft Flow:
      
      body('<Action_name>')?['ResultSets']
      Which you may reference the detailed value by adding:
      
      body('<Action_name>')?['ResultSets']?['FieldName']?

      When I run my flow, I do get a ResultsSets in my output but itĀ appears to be empty. But maybe it’s just indicating it’s an array without showing me what’s in it?

      I just can’t figure out how to get that expression to work to reference the output from the previous step.

      ——————————
      Andy Tippin
      ——————————
      ——————————————-

    • Brent Mason

      Member

      April 17, 2020 at 9:53 AM

      As a work around, if it is an option, you could modify to stored procedure to write it’s output to a SQL table and then read the input via standard SQL connector and PowerApps Filter/Lookup etc.

      ——————————
      Brent Mason
      Project Manager
      5037995914
      ——————————
      ——————————————-

    • Steve Bolton

      Member

      April 20, 2020 at 8:24 AM

      One thing you may want to check is to verify the Stored Procedure has SET NOCOUNT ON.Ā  This prevents the query from returning record count statistics that can confuse Power BI. Not sure how it affects Power Apps.

      CREATE procedure [dbo].[sp_JobsForecastByWeek]
      AS
      SET NOCOUNT ON

      ——————————
      Steve Bolton
      Sr. Business Analyst
      ——————————
      ——————————————-

    • Andy Tippin

      Member

      April 20, 2020 at 10:29 AM

      Ā 
      Thanks for the reply. I double checked, and the sproc does indeed have SET NOCOUNT ON.
      I’ve contacted our DBA to see if he can output to a table that I can just pull from but haven’t heard anything back yet. It’s just really annoying that it works for the guy on the internet but doesn’t work for me.?

      ——————————
      Andy Tippin
      ——————————
      ——————————————-

    • Marcello Brocchi

      Member

      April 28, 2020 at 9:36 PM

      Hi Andy,

      I recently posted a video that covers the subject of using SQL and Power Apps and includes methods on how to retrieve data correctly from Power Automate and use that data within Power Apps. Here’s a link –Ā 

      SQL and PowerApps

      https://youtu.be/awsNLPGNI4w

      ——————————
      Marcello Brocchi
      Software Engineer
      ——————————
      ——————————————-

    • Andy Tippin

      Member

      April 29, 2020 at 3:13 PM

      That was very helpful, thank you.
      Unfortunately, I’m still not getting any output from my sproc and I have no idea why. My SQL is on-prem accessed through a gateway. The db and sproc list populates which tells me there’s no connection/authentication issues…

      I test and it says it ran successfully but I have nothing in my results set. I run the sprocs in SSMS and they work fine. I’ve even tried tweaking them to return less than 500 rows thinking that might be an issue.. no joy.?

      ——————————
      Andy Tippin
      ——————————
      ——————————————-

    DSC Communities replied 5 years, 4 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

The discussion ‘SQL Stored Procedures to PowerApps’ is closed to new replies.

Start of Discussion
0 of 0 replies June 2018
Now

Welcome to our new site!

Here you will find a wealth of information created for peopleĀ  that are on a mission to redefine business models with cloud techinologies, AI, automation, low code / no code applications, data, security & more to compete in the Acceleration Economy!