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 / Update a SharepointLis...
Power Apps
Answered

Update a SharepointList Item or create new

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello guys, 

 

I try to store Items in sharepoint list, or update them. (See picture)

 

RiccoHipp_0-1639060072045.png

Now I have the problem, with the following code 

Patch(
 Abteilungen,
 First(Filter(Abteilungen,Title)),
 {
 'Anzahl Mitarbeiter':Value(Abt_Mit.Text)
 }
);

I only update I should update the amount of Employees. (Which isn't working but that's not the point)

 

But I cant create new items in that list with that code, therefor that code would work 

Patch(
 Abteilungen,
 Defaults(Abteilungen),
 {
 Title: Abteilung.Text,
 'Anzahl Mitarbeiter':Value(Abt_Mit.Text)
 }
);

But this doesn't allow updating one of them, just make duplicates.

 

I thought about some solutions but can't get them into power apps code.

 

In words would be like:

If (Abteilungen.Text equals one title in the sharepoint list )
 -> {update this entry}
else 
 -> {create new}

But how can i get this working.

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    155,972 Most Valuable Professional on at

    Hi @Anonymous ,

    Assuming Title is the unique identifier here

    With(
     {
     wID:
     LookUp(
     Abteilungen,
     Title = Abteilung.Text
     ).ID
     },
     Patch(
     Abteilungen,
     If(
     IsBlank(wID),
     Defaults(Abteilungen),
     {ID:wID}
     ),
     {
     Title: Abteilung.Text,
     'Anzahl Mitarbeiter':Value(Abt_Mit.Text)
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Nearly perfect but in the 

    {ID:wID} 

     Power Apps tell me the following error

    Invalid argument type(Record). Expecting a Boolean value instead.
  • Verified answer
    WarrenBelz Profile Picture
    155,972 Most Valuable Professional on at

    @Anonymous ,

    ID is numeric - not sure on the Boolean reference, but you could try

    With(
     {
     wRecord:
     LookUp(
     Abteilungen,
     Title = Abteilung.Text
     )
     },
     Patch(
     Abteilungen,
     If(
     IsBlank(wRecord.ID),
     Defaults(Abteilungen),
     {ID:wRecord.ID},
     ),
     {
     Title: Abteilung.Text,
     'Anzahl Mitarbeiter':Value(Abt_Mit.Text)
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    No, there also pops up the "name isn't valid error"

  • WarrenBelz Profile Picture
    155,972 Most Valuable Professional on at

    @Anonymous ,

    That relates to the values you posted - what name does the error relate to?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    RiccoHipp_0-1639135795826.png

    Maybe I should tell you more:

     

    Textfeld 1: Abteilungen

    Textfeld 2: Abt_Mit

     

    The Sharepoint List looks like this:

    RiccoHipp_1-1639135930004.png

     

  • WarrenBelz Profile Picture
    155,972 Most Valuable Professional on at

    @Anonymous ,

    You have wID at the top and wRecord.ID at the bottom.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    You're right. I'm sorry. My bad.

    Ichanged that but this ends in the same error with expecting boolean

  • Verified answer
    WarrenBelz Profile Picture
    155,972 Most Valuable Professional on at

    @Anonymous ,

    Your brackets are in the wrong place in the Patch.

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @WarrenBelz 

     

    After some updates it didn't work for me, but I found a solution: 

     

    With(
     {
     wRecord: LookUp(
     Abteilungen,
     Title = Abteilung.Text
     )
     },
     If(
     IsBlank(wRecord),
     Patch(
     Abteilungen,
     Defaults(Abteilungen),
     {
     Title: Abteilung.Text,
     'Anzahl Mitarbeiter': Value(Abt_Mit.Text)
     }
     ),
     Patch(
     Abteilungen,
     First(
     Filter(
     Abteilungen,
     Title = Abteilung.Text
     )
     ),
     {
     Title: Abteilung.Text,
     'Anzahl Mitarbeiter': Value(Abt_Mit.Text)
     }
     )
     )
    )

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

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 305 Most Valuable Professional

#2
11manish Profile Picture

11manish 212

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard