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 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.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,378)