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 Apps
Answered

Patch

(0) ShareShare
ReportReport
Posted on by 728

I am creating an app that has 3 quizzes, each quiz has 2 parts.  the user can do the quizzes in any order.

 

I am trying to add an if function to say that if record exists then update record in sharepoint list, if record doesnt exist the create a new record.

 

I am using the patch function.  This is what i have at the minute:

 

If(
 IsEmpty(
 Filter(
 DiagnosticTesting,
 Email = User().Email
 )
 ),
 Patch(
 DiagnosticTesting,
 Defaults(DiagnosticTesting),
 {
 Title: User().FullName,
 Email: User().Email,
 Numeracy: Label3_1.Text
 }
 ),
 Patch(
 DiagnosticTesting,
 First(
 Filter(
 DiagnosticTesting,
 Email = User().Email
 )
 ),
 {Numeracy: Label3_1.Text}
 )

 

It appears to be working but i have a delegation issue on the First(Filter( section.  How can i resolve this issue?

 

thanks

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @neill_long 

    Please consider changing your Formula to the following:

    Patch(
     DiagnosticTesting,
     Coalesce(LookUp(DiagnosticTesting, Email = User().Email), Defaults(DiagnosticTesting),
     {
     Title: User().FullName,
     Email: User().Email,
     Numeracy: Label3_1.Text
     }
    )

    This will patch an existing record if found, otherwise it will create the record.

     

    I hope this is helpful for you.

  • neill_long Profile Picture
    728 on at

    thank you for this.  i have tried this but now the data doesn't seem to display in the sharepoint list.  It looks like a new record has been created but the fields are empty.

     

    would you have any advice on how to resolve that?

     

    thanks

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

    @neill_long 

    You should be getting some values in there.  Sometimes the User function causes data delays (update occurs before the values are present), so you can consider changing to this (also noticed that I left out a closing paren in the original formula...changed below):

    With({_usr: User()},
    
     Patch(
     DiagnosticTesting,
     Coalesce(LookUp(DiagnosticTesting, Email = _user.Email), Defaults(DiagnosticTesting)),
     {
     Title: _usr.FullName,
     Email: _usr.Email,
     Numeracy: Label3_1.Text
     }
    )

     

    Also, if your Numeracy column is a numeric column, then change the Label3_1.Text to Value(Label3_1.Text)

     

     

  • neill_long Profile Picture
    728 on at

    It has worked!  It was because of the closing paren that was missing.

     

    thanks very much for your help.

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

    @neill_long 

    Oh my...sorry about that!  We type these formulas in free-hand in the forum, so we don't have the aid of the formula editor to check our work...just our eyes - and sometimes they deceive. 

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 234 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard