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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Is it fine to write fo...
Power Apps
Answered

Is it fine to write formula after SubmitForm()

(0) ShareShare
ReportReport
Posted on by 2,015 Season of Giving Solutions 2025

I have a form and 4 buttons... now when clicking on some button i will be submitting the Form and return the users to the main screen. while on other scenarios after submitting the form i need to Patch and clear some collections for SharePoint items. so generally speaking is it fine to write formula after form submission something as follow:-

 

 

If(IsEmpty(colNetworkConflicts),
If(IsEmpty(colSelectedMedia) Or IsEmpty(colSelectedNetworks),
Notify("Please select atleast one Network and one Medium",NotificationType.Error),
SubmitForm(BookingCalendarForm))
,
Notify("Conflict found, Please check the Booking calendar for more info",NotificationType.Error));
Clear(colDelegableresults);
Clear(colNetworkConflicts);

 

or as follow:-

 

SubmitForm(PrintFormForm);

Office365Outlook.SendEmailV2(
 PrintFormForm.LastSubmit.'Printing House Email',
 PrintFormForm.LastSubmit.'Email Subject',
 PrintFormForm.LastSubmit.'Email Body',
 {
Attachments:Table({
 Name: varAttachment.DisplayName,
 ContentBytes: varAttachment.Value
})

or the formula after the SubmitForm() will not get executed/reached?

Categories:
I have the same question (0)
  • M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @johnjohnPter ,

    Try this

    SubmitForm(BookingCalendarForm);
    Clear(colDelegableresults);
    Clear(colNetworkConflicts);
    // Additional logic after form submission

    Fuel our success! 🚀 Give a thumbs up and click 'Solution Accepted' to supercharge our community. Your actions speak volumes!
    Warm regards,
    Muhammad Ali

  • johnjohnPter Profile Picture
    2,015 Season of Giving Solutions 2025 on at

    @M_Ali_SZ365 did you read my question? as seems your answer is not related to it. thanks

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @johnjohnPter,

    If you want to do something after form submission, to ensure the form is submitted successfully, you could write the other operation like your Patch() or Clear() on the OnSuccess property of the form.

     

    If there is no invalid error in your form, actions will be operated after your form submission.

  • johnjohnPter Profile Picture
    2,015 Season of Giving Solutions 2025 on at

    @v-qiaqi-msft but as i mentioned that the form can be submitted by the other buttons where i do not want to perform the patch.. so that why i am writing it after the SubmitForm() on the button onselect and not on the form onsuccess.. so again to return to my question, will the formulas that comes after the SubmitForm() get executed?

  • v-qiaqi@microsoft.com Profile Picture
    Microsoft Employee on at

    Hi @johnjohnPter,

    I have answered it in my previous reply.

     

    If there is no invalid error in your form, actions will be operated after your form submission, which is after the SubmitForm() get executed.

  • Verified answer
    timl Profile Picture
    37,233 Super User 2026 Season 1 on at

    @johnjohnPter 

    The direct answer to this question is yes, the formulas after SubmitForm will be executed.

    >> will the formulas that comes after the SubmitForm() get executed?

     

    However, it would be preferable to add the additional formulas to the OnSuccess property of the form so that they run only when the call to SubmitForm succeeds.

    Before calling SubmitForm, you can set a variable that identifies the button that was clicked.

     

    Button1.OnSelect -
    UpdateContext({locButton:"Button1"});
    SubmitForm(Form1)
    
    Button2.OnSelect -
    UpdateContext({locButton:"Button2"});
    SubmitForm(Form1)
    
    Button3.OnSelect -
    UpdateContext({locButton:"Button3"});
    SubmitForm(Form1)


    You can then refer to this variable in the OnSuccess to execute the calls to Patch/Clear/SendEmail depending on the source button.

    Form1.OnSuccess - 
    
    Switch(locButton,
     "Button1",
     <Optional Patch/Clear operations for button 1>,
     "Button2",
     <Optional Patch/Clear operations for button 2>,
     "Button3",
     <Optional Patch/Clear operations for button 3>
    )
    

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 305 Most Valuable Professional

#2
11manish Profile Picture

11manish 212

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard