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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@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.

 

 

@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 below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,132)