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 / Order of code is causi...
Power Apps
Answered

Order of code is causing one option to not submit

(0) ShareShare
ReportReport
Posted on by 22

Hello, I am confused and trying to understand why everything in this code below works accept if I choose Assigned as an option it will only send the email not submit the form. I also assume there is a more streamlined way to write this code out. 

Any help would be appreciated!

If(
DataCardValue14.Selected.Value = "Assigned", Office365Outlook.SendEmailV2("......","Your request has been accepted and is being worked on”","Body");
DataCardValue14.Selected.Value = "New", UpdateContext({DenialPopUpVIS:false});
DataCardValue14.Selected.Value = "Assigned", UpdateContext({DenialPopUpVIS:false});
DataCardValue14.Selected.Value = "Complete", UpdateContext({DenialPopUpVIS:false});
DataCardValue14.Selected.Value = "Denied", UpdateContext({DenialPopUpVIS:true});
({DenialPopUpVIS:false}), SubmitForm(Form1))

 

Categories:
I have the same question (0)
  • madlad Profile Picture
    2,637 Moderator on at

    It's because the if statement will not check the rest of the options once one has returned true- You should update the context variable in the same 'true value' as you send the email.

     

    Hope this helps!

  • Gtruddy5922 Profile Picture
    22 on at

    Could you possibly show what this would look like?

    Thanks!

  • madlad Profile Picture
    2,637 Moderator on at

    You might have to make some minor modifications, but it could be something like this:

    If(
     DataCardValue14.Selected.Value = "Assigned", 
     Office365Outlook.SendEmailV2(
     "......",
     "Your request has been accepted and is being worked on”",
     "Body"
     );
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "New", 
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "Complete", 
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "Denied", 
     UpdateContext({DenialPopUpVIS:true})
    );
    If(
     ({DenialPopUpVIS:false}), 
     SubmitForm(Form1)
    )
    
     

     

  • Gtruddy5922 Profile Picture
    22 on at

    This did not work for me, do you have any other ideas?

  • madlad Profile Picture
    2,637 Moderator on at

    how didn't it work- Is it throwing errors, or same issue as before? or something else entirely?

  • Gtruddy5922 Profile Picture
    22 on at

    All of this was marked as an error.

    If(
     ({DenialPopUpVIS:false}), 
     SubmitForm(Form1)
    )

     

  • madlad Profile Picture
    2,637 Moderator on at

    What's the error?

  • Gtruddy5922 Profile Picture
    22 on at

    I hope this is what you mean

    Screenshot (2).png
  • Verified answer
    madlad Profile Picture
    2,637 Moderator on at

    Woops... I accidentally messed up the code I sent you it seems 😐

    try

    If(
     DataCardValue14.Selected.Value = "Assigned", 
     Office365Outlook.SendEmailV2(
     "......",
     "Your request has been accepted and is being worked on”",
     "Body"
     );
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "New", 
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "Complete", 
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "Denied", 
     UpdateContext({DenialPopUpVIS:true})
    );
    If(
     DenialPopUpVIS, 
     SubmitForm(Form1)
    );

     

    I should also mention that this code assumes you only submit if DenialPopupVIS is true. If that's not the case, and you always submit, try this instead:

    If(
     DataCardValue14.Selected.Value = "Assigned", 
     Office365Outlook.SendEmailV2(
     "......",
     "Your request has been accepted and is being worked on”",
     "Body"
     );
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "New", 
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "Complete", 
     UpdateContext({DenialPopUpVIS:false}),
     DataCardValue14.Selected.Value = "Denied", 
     UpdateContext({DenialPopUpVIS:true})
    );
    SubmitForm(Form1);

     

  • Gtruddy5922 Profile Picture
    22 on at

    That works! Thank you!!!

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard