cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vignesh_2112
Helper II
Helper II

PowerApps Patch function to SharePoint

Hi

 

I have created a SharePoint list where the user data will be patched from the PowerApps entry.

Now, I require to have two different Apps - one for a particular set of users and another for the rest.

 

So, the first Application should patch all the columns of the SharePoint list when submitted. Then, the second application have to replace some of the patched data first application submission, once submitted.

 

Is it possible to do it?

 

I tried but the SharePoint list is updated with new row of data. Whereas I need the existing row submitted using first app to be replaced by the second application (not all the columns, but a few)

 

Thanks

Vignesh_2112

1 ACCEPTED SOLUTION

Accepted Solutions

@Vignesh_2112 

If it's only the last record that you want then consider this in the formula:

UpdateIf('FTE Application',
    ID=First(
          SortByColumns('FTE Application', "Created", Descending)
       ).ID,
    {Remote:T20.Text, MOC:T21.Text, 
     'Equipment Accepted':T22.Text, 
     'Gen Comments':T23.Text, 
     'Area Imp':T24.Text, 
     Rating:Value(T25.Text), 
     'Client name':T26.Text, 
     'Date Ins':DatePicker1.SelectedDate
    }
)

 

That will give you the most recently created record and then update it.

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

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@Vignesh_2112 

Your biggest priority will be that you need to refresh your datasource in the apps OFTEN and before you submit any data to them.

If App 1 makes a record in SP, App 2 will not know about it until App 2 does a refresh on the datasource.

Once you have that in place, then yes, what you want to do will work just fine with Patch - however, you might want to explore using UpdateIf rather than Patch for updates as Patch has some little oddities with SharePoint datasources.

 

I hope this is helpful for you.

_____________________________________________________________________________________
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 

 

Thanks for your reply.

 

I just have textbox to be patched by Application 1, and similarly tried to use patch function for application 2.

Since, you have quoted to use UpdateIf on the second application, am I right?

 

Is there an option to schedule refresh the SharePoint list to enable this ?

 

Thanks

Vignesh_2112

@Vignesh_2112 

You can use the Patch function, I only mention UpdateIf as a little more reliable in some situations.

 

As for the refresh, that is going to be up to you in your App.  You could utilize a timer to schedule a periodic refresh, or depending on how you need to display information or update it, you could do a refresh prior to performing a Patch/UpdateIf.  

BUT, the key is, your app will not do that automatically without your designing it to do so.  And, if you want to have 2 apps using the same datasource and working on the same data simultaneously, then you will need to incorporate that into your design.

_____________________________________________________________________________________
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 tried patch function in both the apps, but the SharePoint is getting updated with new record everytime. 

It doesn't seem to replace the existing record values in the columns of SP list

 

I assigned a patch function to OnSelect property of Submit button to store the date in SP.

Then opened the second application and used the patch function to a submit button to update the record in the columns. But, a new record is getting stored.

 

PFA . I have highlighted the data for your reference

 

Thanks

Vigneshraj C T

@Vignesh_2112 

So what are your Patch formulas?  They need to specify the proper record to patch.

_____________________________________________________________________________________
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 

 

Application 1 Submit button:

Patch(SharePoint list name1, Defaults(SharePoint list name1), {Title: TextInput1.Text, Name: TextInput2.Text, Coulmn 3 name: TextInput3.Text,etc..})

 

Application 2 Submit button:

Patch(SharePoint list name1, Defaults(SharePoint list name1), {Title: TextInput4.Text, Name: TextInput5.Text, Coulmn 3 name: TextInput6.Text,etc..})

 

Thanks

Vigneshraj C T

@Vignesh_2112 

Yes, so both statements are creating new records.  That is what Defaults does...gives you a blank default record.

 

If you want to patch an existing record, you need to get it first, or identify it.

 

"Get It First" Example:

Patch(myList, Lookup(myList, someFilterCriteriaToGiveYouARecord),
    {Title:"Something",
     Another:"More",
     etc...
    }
)

 

"Identify It" Example:

Patch(myList, Lookup(myList, ID=x),
    {Title:"Something",
     Another:"More",
     etc...
    }
)

Or in the above case, easier with:

UpdateIf(myList, ID=x,
    {Title:"Something",
     Another:"More",
     etc...
    }
)
_____________________________________________________________________________________
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 

I used the following formula, check whether it is correct:

 

UpdateIf('FTE Application',!IsEmpty('FTE Application'),{Remote:T20.Text, MOC:T21.Text, 'Equipment Accepted':T22.Text, 'Gen Comments':T23.Text, 'Area Imp':T24.Text, Rating:Value(T25.Text), 'Client name':T26.Text, 'Date Ins':DatePicker1.SelectedDate})

 

Can I use !IsEmpty function ?

 

Thanks

Vignesh_2112

@Vignesh_2112 

So, what your formula will do is to update every record in your data source.  The reason is that the second parameter of the UpdateIf is the condition to check for.  In your case you are using !IsEmpty('FTE Application') which is always going to evaluate to true.  And thus, UpdateIf will apply to every record.

 

What you need there is something that will identify the record you are working with in the list.  Usually with SharePoint, for a particular record, you would use its ID.

So, UpdateIf('FTE Application', ID=<someID>, {your changes})

The question is, how are you identifying the record you want to change?

Example, if your list has 100 records in it, which one do you want to update, and how do you determine it?

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

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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