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 am completely Blank.....

 

Yes all the data types are in the same way just as you mentioned. Yet When I combine them in the LookUp function, it is throwing the same error. Failed to fetch the items. Possible invalid string in the query.

 

I am verifying with the exact values present in the SP list.  The ID is coming correctly in the Label when I use static values. The Values are coming correctly when I used &ProjectId. But I am not at all understanding why it is unable to fetch the value when I use

 

LookUp('Source', 'Project Id' = ProjectId && Closing Month= ClosingMonth, ID)

@kiritisaranam 

So, doing a full review of all of our messages...

I see that after you tried to use ProjectId in your formula, you got no return value (ID).

So, let's focus on that a bit.

You said that when you hard coded a value in for ProjectId that you got a result.

So, let's change the label text property to the following:

ProjectId = 1 & " / " & ClosingMonth = "January"

Replace the 1 and the "January" with values you know to be in your list.

 

The label SHOULD read "true / true"

Let's see what you get. 

_____________________________________________________________________________________
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 Result is False. I am assuming the issue is with the closing month.

 When I hover on ProjectId in this statement it says 274=274 but when I hover on closing month it says "FY2021-P02"=FY2021-P02.

 

FYI: My months are in the format of FY2021-P01, FY2021-P02 etc..

@kiritisaranam 

You mention false - there should have been two values "true / true" or "false / true" or "true / false" or "false / false"

Which one did you get?

I seemed to lean more toward the ProjectId being an issue because from before you said that is where it failed and you were not able to get an ID from the LookUp once you introduced that.

_____________________________________________________________________________________
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!

Also I am getting only false. But not false/false or true/false.

 

A warning message is being displayed stating that "Incompatible type. We can't evaluate your formula because the values being compared in the formula aren't the same type."

@kiritisaranam 

Okay...whack a mole here!

 

Let's change the label text property to the following:  Text(ClosingMonth)

What do we get with that?

_____________________________________________________________________________________
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 

When I tried Text(ClosingMonth) it displays FY2021-P02.

@kiritisaranam 

Okay...let's try this then in the text property:

ProjectId = 274 & " / " & Text(ClosingMonth) = "FY2021-P02"

Fingers crossed for "true / 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 I am assuming when you mean by ProjectId and ClosingMonth, these are the variables that I have set in Power App.

 

If the above statement is correct, still no luck. I am getting false and an error stating Incompatible type and cant evaluate the formula which I have mentioned in previous post.

@kiritisaranam 

Okay, we need to get to the source of the issue with that variable then.

Let's go back to the Gallery, but first - go into the View Menu in the designer and click on Variables, then click on Global and then look for your CurrentMonth variable. 

Tell me what it says under the variable for the variable type.  Also what it shows in the right for the value in it.

Perhaps a screenshot of that would be helpful.

_____________________________________________________________________________________
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!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,232)