cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WeAllStardust
Helper I
Helper I

Patching SharePoint if record is present or not

HI,

 

I want to patch a SharePoint list through PowerApps to where it would first "LookUp" the list and see if a person's name is under the Name column. If not, it will add that person's name from a label to the list and add a time stamp to it. If the person's name is already on the list, then it will update the time stamp to now on the list. I want to make it all happen under one button. 

 

I tried using a combination of Patch/Lookup/IsBlank but I'm getting error saying that I cannot patch the same list I am referring to. 

 

I know my code is not correct but what do I need to do to fix it?

 

 

Set(Status, "Available");
Set(TimeStamp, Now());
Set(confirmation, false);

If( IsBlank(List), false, (Patch(List),LookUp(List, PersonName), {PersonName: Label_User.Text, 'Current Status': Label_Status.Text}), (Patch(List),Defaults(List,{PersonName: Label_User.Text, 'Current Status': Label_Status.Text})))

 

 

 

Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@WeAllStardust 

If(
   IsBlank(
            Lookup(
                    list,PersonName=Labe1_User.Text
            )
    ), Patch(
             list,Defaults(list),{PersonName:Labe1_User.Text,
                                  TimeStamp:Now(), 
                                  'Current Status':Label_Status.Text}
       ),
       Patch(
             list,PersonName=Labe1_User.Text,{ TimeStamp:Now(),
                                              'Current Status':Label_Status.Text}
       )
)

View solution in original post

2 REPLIES 2
Drrickryp
Super User
Super User

@WeAllStardust 

If(
   IsBlank(
            Lookup(
                    list,PersonName=Labe1_User.Text
            )
    ), Patch(
             list,Defaults(list),{PersonName:Labe1_User.Text,
                                  TimeStamp:Now(), 
                                  'Current Status':Label_Status.Text}
       ),
       Patch(
             list,PersonName=Labe1_User.Text,{ TimeStamp:Now(),
                                              'Current Status':Label_Status.Text}
       )
)

Thanks for your reply! I had to modify your code a bit to get it to work. The change I did was to replace the second "PersonName = Label_User.Text" with "LookUp(List, PersonName - Label_User.Text)". That was it was looking the table one more time and replacing that information. 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (4,242)