cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kiritisaranam
Microsoft
Microsoft

How to use multiple filters to update a record in sharepoint list using Patch function

 The below mentioned rows are my rows in SharePoint list.

Project IdClosing MonthComments
1JanuaryHi
1FebruaryHello

I have a power app which patches the data to SharePoint. While patching the data, I need to check whether there is an existing entry for the same project id in that closing month and I need to update the record if it already exists and create a new record if that do not exist in that particular month. In the above example, if some one submits an entry for project id 1 and if still the closing month is February it needs to update the entry. This is the query I am using

If(IsEmpty(Filter('Source', Title = ClosingMonth && 'Project Id' = ProjectId)) ,Patch('Source',Defaults('Source'),{'​​Title':ClosingMonth,'Project Id':ProjectId,'Comments':Comments}, Patch('Source',First(Filter('Source', 'Project Id' = ProjectId && Title = ClosingMonth)),{​'Comments':Comments}​​));

But this condition is not working. Appreciate any help.

 

56 REPLIES 56

@RandyHayes I have tried this in Text property and is returning true.

 

If(ClosingMonth="FY2021-P02"&&ProjectId=274," true","false")

@RandyHayes In all my conditions I am using the same values...

 

kiritisaranam_0-1601501728200.png

 

@kiritisaranam 

Okay...still, 

ProjectId = 274 & " / " & ClosingMonth = "FY2021-P02"

Should have returned "true / true".  If there is something with that variable we need to get to the root of it as it is essential in the LookUp formula.

 

So, let's pull the ProjectId out of this as it sounds like that is working.

Set your Text property to :

ClosingMonth = "FY2021-P02"

 This should show true.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes 

ClosingMonth="FY2021-P02" is returning true and ProjectId=30052 is also returning true in the Label.

@kiritisaranam 

Hmmm...let's solve this mystery.

 

Test1:

   Text property : 

LookUp('Source', 'Closing Month'= ClosingMonth, ID)

Any Value? 

 

Test2:

   Text property:

LookUp('Source', 'Project Id' = ProjectId, ID)

Any Value?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

kiritisaranam_0-1601502653924.png

@RandyHayes Regardless of what ever I write after & it is giving me only false.

 

 

@kiritisaranam 

Yes, that would be false as the closingmonth is not "FY2021-P02Hi"

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes Hurray!!! We cracked it finally.

 

The catch is that as my button is residing outside the gallery where I have set the variables, In some other article I have read that we need to select Galleryname.selected.variable to compare with the SP List and it worked.

 

Thank you so much for providing the optimal solution. My App is working very fast now with your logic. Appreciate your help and appreciate your patience.

 

For the people who checks this thread for solution, please check this final post and refer to the main logic given by Randy.

 

 

View solution in original post

@kiritisaranam 

Excellent!!!  I knew we would get there.  Even if we ended up writing a books-worth of messages 😉

 

Glad all is working now!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Hi @RandyHayes , the solution is working fine but it is working only for me. When Others are trying to submit the responses, the records are not getting added to the sharepoint list. Can you help me here in letting me know what I am missing? 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (46,374)