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 / Trigger button using a...
Power Apps
Unanswered

Trigger button using another button while using If

(0) ShareShare
ReportReport
Posted on by 55

Hello mates, 

 

So basically, what I want is when the 2nd submit button is clicked, for it to check the code and the if statement in the 1st submit and if satisfied, to go ahead and run the code in button 1 which will add the number. 

 

Whenever I click on either button, it seems to ignore the 2nd if and just add the number regardless. 

Here is the code:

The varSubmit is the second submit button which has Set(varSubmit,Select(btnSubmit_7)) on its OnSelect. btnSubmit_7 is the 1st submit button.

 

If(
CountRows(errorGallery.AllItems) < 1,
Patch(
Leads,
Defaults(Leads),
{
LeadContactName: txtContactName.Text,
LeadPhone: txtContactPhone.Text,
LeadContactNotes: txtNotes.Text,
LeadEntryDate: Date.SelectedDate,
AgentEmail: vAgent.AgentEmail,
crb4e_lead: Concatenate(
txtContactEmail.Text,
" -- ",
Now()
)
}
),
varSubmit && CountRows(errorGallery.AllItems) > 1,
Patch(
Leads,
Defaults(Leads),
{
LeadContactName: txtContactName.Text,
LeadPhone: txtContactPhone.Text,
LeadContactNotes: txtNotes.Text,
LeadEntryDate: Date.SelectedDate,
AgentEmail: vAgent.AgentEmail,
crb4e_lead: Concatenate(
txtContactEmail.Text,
" -- ",
Now() )}
);
UpdateContext({varResubmit: true})
);

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @sergeasmar97 

    Not sure what you mean by the difference buttons. Perhaps you can expand more on that.

    Your Patch formulas are identical in your true and false part of the formula - so what is the significance of duplicating the formula?

  • sergeasmar Profile Picture
    2 on at

    .

  • sergeasmar97 Profile Picture
    55 on at

    Let me elaborate. The app checks for duplicate phone number. If not found, then the phone number is patched. If found, then another submit button shows with the message “duplicate phone found. Proceed?”. I want the user to be able to click on the second submit button to submit again. So basically, the condition that differs first from second if is the button click.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @sergeasmar97 

    So why not simply let the user know there is a duplicate and to proceed from the very start?

     

    What is the Items property of errorGallery and how does that play into this?

  • sergeasmar97 Profile Picture
    55 on at

    Basically, what I need is for the click of another button to be a condition in the if statement above. How do i do that? I tried creating varSubmit as the select variable in the second button, but it didnt work. Check the code above. This is what i set on the second button: Set(varSubmit,Select(btnSubmit_7))

  • sergeasmar97 Profile Picture
    55 on at

    This is the items property of errorgallery: Filter(Leads, txtContactPhone.Text = LeadPhone)

     

    It displays the names of the records with duplicate phone numbers. So when a duplicate phone number is written, the gallery shows displaying the records with the same number written.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 936

#2
Valantis Profile Picture

Valantis 604

#3
11manish Profile Picture

11manish 518

Last 30 days Overall leaderboard