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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch function inside ...
Power Apps
Answered

Patch function inside of if statement not working

(0) ShareShare
ReportReport
Posted on by 16
Hello! I have a submit button at the end of my form that is supposed to update a SharePoint list if certain conditions are not met:
 
Here as an example of the function:
;If(Conditions1.Text = "false",
    Patch(
        TestList,
        LookUp(
            TestList,
            Name = UserName.Text
        ),
        {
            'Start': Start.Selected.Value,
            'Lunch Start': LunchStart.Selected.Value,
            'Lunch End': LunchEnd.Selected.Value,
            'End': End.Selected.Value,
        }
    );Set(Updated1, true))
 
 
There are 7 different (but similar) sets of conditions that each have a similar function as the one listed above. I know that the patch function on its own works as I have it so certain fields are always patched and they seem to be working fine.
 
Example:
Patch(TestList,
        LookUp(
            TestList,
            Name = UserName.Text
        ),
        {
            'Leave Start': LeaveStart.SelectedDate,
            'Leave End': LeaveEnd.SelectedDate,
        })
; Set(Updated8true)
 
Interestingly, the following patch statement also appears to be working as intended:
 
;If(AdditionalNotes.HtmlText = "Enter any additional notes here.", Set(UpdatedFinal, true), Patch(TestList,
        LookUp(
            TestList,
            Name = UserName.Text
        ),
        {
            'Additional Notes': AdditionalNotes.HtmlText
        }
        );Set(UpdatedFinal, true))
 
 
I honestly have no idea what may be causing this issue. Any solutions would be greatly appreciated. Thank you! 
Categories:
I have the same question (0)
  • rzuber Profile Picture
    545 Moderator on at

    Are you receiving an error? Is it a syntax issue? I'm seeing an extra comma at the end of some of your records.

  • a51 Profile Picture
    16 on at

    Hi @rzuber! No I am not receiving any errors. The other functions that occur at the same time are also working fine. The extra commas in the patch functions are because there are a few more values that are being patched, the actual final value in the patch function doesn't end in a comma. 

  • rzuber Profile Picture
    545 Moderator on at

    Is UserName.Text user input?

     

    Is there a possibility of a case issue?

     

    If so, you could change your lookups to:

    LookUp(
     TestList,
     Lower(Name) = Lower(UserName.Text)
    )

     

  • a51 Profile Picture
    16 on at

    No, UserName is actually determined by a single selection combo box. Which I then convert into a .text output using 

    Concat(NameSelect.SelectedItems, Title). UserName.Text is the output of this function.
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    hey @a51 

     

    can u try this:

    If(
     Conditions1.Text = "false",
     Patch(
     TestList,
     LookUp(TestList, Name = UserName.Text),
     {
     'Start': Start.Selected.Value,
     'Lunch Start': LunchStart.Selected.Value,
     'Lunch End': LunchEnd.Selected.Value,
     'End': End.Selected.Value
     }
     );
     Set(Updated1, true)
    );
    If(
     Conditions2.Text = "false",
     Patch(
     TestList,
     LookUp(TestList, Name = UserName.Text),
     {
     'OtherField': OtherValue.Selected.Value
     }
     );
     Set(Updated2, true)
    );
    // Repeat for other conditions
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • rzuber Profile Picture
    545 Moderator on at

    @a51 - What are the possible values of Conditions1.Text?

  • Verified answer
    a51 Profile Picture
    16 on at

    Hi everyone I was able to fix the problem. By reversing my conditions (ex: variable1=false to variable1=true) and writing them out manually rather than using a text output based those conditions, the patch functions are now working as intended. Thanks to everyone who tried to help me with this issue!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 380 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 340

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 333 Super User 2025 Season 2

Last 30 days Overall leaderboard