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 / Powerapps button to ac...
Power Apps
Answered

Powerapps button to action request but only if certain conditions are met

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all

 

I know this one is going to be easy and I feel like I'm right there but I can't quite figure out how to achieve what I'm trying to achieve.

 

I have a app that is going to record fuel purchases.

 

I have some fields that I want to be "required" before submission is allowed.

 

On top of that, I have one field that, if left blank, I want it to patch the number "0" to Sharepoint, if it has a number entered, I want it to patch that number. I know I can default this text input to zero but I'd rather not if I can help it.

 

I think I may need nested If statements but I can't figure out how to make it work after many iterations of the code.

 

The app looks like this:

 

Capture.JPG

 

And the current code is like this:

 

If(!IsBlank(RegoLabel) && !IsBlank(KMsTextInput) && !IsBlank(FuelTextInput) && !IsBlank(CostTextInput) && AdBlueTextInput.Text = "",

Patch(FuelRegister, Defaults(FuelRegister), {Driver: DriverLabel.Text, Vehicle: VehicleSelectDropdown.Selected, Rego: RegoLabel.Text, Kilometres:Value (KMsTextInput.Text),Fuel:Value (FuelTextInput.Text), AdBlue: 0.0, TotalCost:Value (CostTextInput.Text)}),

 

Patch(FuelRegister, Defaults(FuelRegister), {Driver: DriverLabel.Text, Vehicle: VehicleSelectDropdown.Selected, Rego: RegoLabel.Text, Kilometres:Value (KMsTextInput.Text),Fuel:Value (FuelTextInput.Text), AdBlue:Value (AdBlueTextInput.Text), TotalCost:Value (CostTextInput.Text)}))

 

;UpdateContext({PopUp: true})

 

This is not doing what I need it to as it will patch the second set of data if any of the first conditions are not met which isn't what I want.

 

Any help you can give me would be much appreciated.

 

Thank you 🙏

Categories:
  • Verified answer
    v-siky-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Please try to modify your codes as follows, nest 'AdBlueTextInput.Text = ""' condition into the AdBlue field value part code.

     

    If(!IsBlank(RegoLabel) && !IsBlank(KMsTextInput) && !IsBlank(FuelTextInput) && !IsBlank(CostTextInput) ,

    Patch(FuelRegister, Defaults(FuelRegister), {Driver: DriverLabel.Text, Vehicle: VehicleSelectDropdown.Selected, Rego: RegoLabel.Text, Kilometres:Value (KMsTextInput.Text),Fuel:Value (FuelTextInput.Text), AdBlue: If(AdBlueTextInput.Text = "",0.0,Value (AdBlueTextInput.Text)), TotalCost:Value (CostTextInput.Text)}))

    Hope this helps.

    Sik

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you @v-siky-msft 

     

    I knew that wasn't going to be a tough one but it had me stumped!

     

    Have a good day 🙏

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard