cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
silkwire
Helper I
Helper I

How do I access the response of a Submit function?

I am looking to access the response of a Submit function. I want to use the primary key that was associated with the response and patch it in as a foreign key to another table on the same button click.

 

I remember reading somewhere that I can access the result of a Submit... but can't find it now.

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

If you want to get the result of a form submission, you can look at the LastSubmit property of the form control in the OnSuccess property of the form itself.

Below is a (simplified) example of an app that I have. In this app the user can enter orders, which contains different items. The items are stored in a collection, and the order is entered using a form (called Form1 in the example below). When the order is submitted successfully, the form's OnSuccess property (shown below) is executed and inserts all items for the order in the appropriate table, using the id of the recently inserted order as the foreign key.

ForAll(
    tempItems,
    Patch(
        '[PowerAppsTest].[OrderItem]',
        Defaults('[PowerAppsTest].[OrderItem]'),
        {
            OrderId: Form1.LastSubmit.Id,
            Product: Name,
            Quantity: Quantity,
            Price: Price
        }));
Clear(tempItems)
Navigate(Screen2, ScreenTransition.Cover)

Hope this helps!

View solution in original post

2 REPLIES 2
silkwire
Helper I
Helper I

Errr, to clarify, it's the SubmitForm function. Thanks!

CarlosFigueira
Power Apps
Power Apps

If you want to get the result of a form submission, you can look at the LastSubmit property of the form control in the OnSuccess property of the form itself.

Below is a (simplified) example of an app that I have. In this app the user can enter orders, which contains different items. The items are stored in a collection, and the order is entered using a form (called Form1 in the example below). When the order is submitted successfully, the form's OnSuccess property (shown below) is executed and inserts all items for the order in the appropriate table, using the id of the recently inserted order as the foreign key.

ForAll(
    tempItems,
    Patch(
        '[PowerAppsTest].[OrderItem]',
        Defaults('[PowerAppsTest].[OrderItem]'),
        {
            OrderId: Form1.LastSubmit.Id,
            Product: Name,
            Quantity: Quantity,
            Price: Price
        }));
Clear(tempItems)
Navigate(Screen2, ScreenTransition.Cover)

Hope this helps!

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (3,580)