web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Error in Canvas App: "...
Power Apps
Unanswered

Error in Canvas App: "Invalid Argument Type" When Calling Stored Procedure

(1) ShareShare
ReportReport
Posted on by 4

Context:

The stored procedure works fine in Power Automate, but I encounter an issue in Power Apps when trying to store the result in a variable or collection. The error occurs when accessing .Table1 from the result set.

Power Fx Formula Where the Error Occurs:

Set(ResultData, ParseJSON(Test.STOREDPROCEDURE(...).ResultSets.Table1));

I’ve tried using ParseJSON() to convert the result set to a typed object, but I still get the "Invalid argument type" error when trying to access fields from .Table1. Even when storing the result in a variable instead of a collection, I face the same issue.

Attempts to Resolve:

  • I've tried using Text(), Value(), and even ForAll() to convert and extract values from the result set, but I continue to encounter the error.
  • I followed the documentation on handling untyped results, but still cannot properly parse the JSON data and store it in a variable.

Here’s an overview of what I’m doing:

  1. Retrieving JSON Data: I am calling a stored procedure and storing the JSON output in a variable:
     
    Set(varsiteproviders, callstoredprocedure(site_id));
     
  2. Extracting the Table from JSON Data:
 
      Set(varsiteprovidertable, varsiteproviders.Table1);
 
       3. Attempting to Parse and Store in a Variable:
     Set(varTypedTable, ForAll(varsiteproviderstable, { Field1: ThisRecord.Field1, Field2: ThisRecord.Field2 }));

However, I get the error message "Formula contains data where indent is expected" when trying to set the varTypedTable variable.

I have verified that varsiteproviders and varsiteprovidertable contain valid JSON data, and Power Automate successfully runs the same stored procedure. However, I’m trying to eliminate Power Automate due to performance concerns.

Expected Outcome:

I would like to store the result of the stored procedure in a Power Apps variable or collection and access the table’s fields without encountering the untyped object error.

Question:

How can I properly handle the stored procedure result in Power Apps to avoid this error? Should I convert the result into another format or use different Power Fx functions to handle the untyped object?

Any guidance or alternative approaches would be appreciated! Thank you.

Categories:
I have the same question (0)
  • Suggested answer
    Ravindra Jadhav Profile Picture
    342 Moderator on at
    1. Run the stored procedure:

      Set(varsiteproviders, callstoredprocedure(site_id));
       
    2. Access the table from the result:
      Use First(varsiteproviders).Value to retrieve the untyped table.

    3. Display data in a gallery:
      In a gallery, set the label's Text property to ThisItem.ColumnName to access fields from the untyped object.

    This approach should help avoid the "Invalid argument type" error and allow you to work with the stored procedure result in Power Apps.

    Please Closed the Question, Mark it Solved 
     
    If my answer helped resolve your issue, please consider marking it as solved to assist others facing the same problem. Additionally, giving it a like would be greatly appreciated and motivates us to keep helping
     
    Thank You
    Ravindra Jadhav
  • Suggested answer
    Meekou Profile Picture
    200 Moderator on at
    For accessing data from Stored procedure by PowerApps, there is no need to use ParseJson to convert the result, in general it will return table directly.
    Something like 
    You need to access by ResultSets.Table1.
    For your original code, do not need to use ParseJson, for your appempts, make your variable match like below:
    Set(varsiteproviders, meekoudb.dboGetUsers());
    Set(varsiteprovidertable, varsiteproviders.ResultSets.Table1);
    Set(varTypedTable, ForAll(varsiteprovidertable, {UserName : ThisRecord.UserName, UserAge: ThisRecord.UserAge}));
    Best Regards,
    Meekou
    Private Support: support@meekou365.onmicrosoft.com
     
  • Suggested answer
    timl Profile Picture
    36,383 Super User 2025 Season 2 on at
    From what you you describe, it sounds as though your Stored Procedure returns JSON - possibly because you've used "For JSON" in your call to Select. 
     
     
     
    Can you confirm whether that's the case? If so, that would explain the issue the behaviour that you're seeing. 
     
    If that's the case, if it's possible for you to modify your stored procedure to not return JSON, that would be the easiest way to resolve this problem.
  • CU21102136-0 Profile Picture
    4 on at
    @meekou I tried your method but still getting same error
     
    If I am trying to call SP directly into collection I am getting following error:
    Set(varsiteproviders, meekoudb.dboGetUsers());
    Set(varsiteprovidertable, varsiteproviders.ResultSets.Table1);
    Set(varTypedTable, ForAll(varsiteprovidertable, {UserName : ThisRecord.UserName, UserAge: ThisRecord.UserAge}));
  • Meekou Profile Picture
    200 Moderator on at
    @CU21102136-0, could you share your defination of Stored Procedure, what data did you return?
    I test with return table data which can access Table1, and here is my test Stored Procedure
    CREATE PROCEDURE GetUsers
    AS
    BEGIN
        -- SET NOCOUNT ON added to prevent extra result sets from
        -- interfering with SELECT statements.
        SET NOCOUNT ON
    
        -- Insert statements for procedure here
        SELECT * From tblUser
    END
    GO
    
    Share a demo Stored Procedure which can reproduce your issue.
    Best Regards,
    Meekou

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard