cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
PierreMichelMat
Regular Visitor

Update Sharepoint list by incrementing value

Hello all, 

 

I am using a Sharepoint list as database. 

I want to set up a button on the Detail Screen of a specific record so that the user can press it and have a value from the DB that get incremented by 1.

Any hint what should be the formula on On Select field of the button?

I have tried the Patch function without success so far as I have trouble with the 2nd and 3rd argument of this function: 

- select the right record to update: this should be easy as I am on the Detail Screen of the record I want to update one field

- increment one field with the old value + 1

 

Thanks for the help!

Best Rgds,

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Update Sharepoint list by incrementing value

@PierreMichelMat 

Being on the Detail screen will definitely make this easier. Here's how I would do it:

 

#1  Add the ID as a new field to the Detail Screen.  Do this by clicking on your form, then Edit Fields on the Right-Side properties menu.

 

#2  Make the ID field invisible because you don't actually want to show it.  Put this code the in Visible property of the datacard.

false

 

#3  Place a new button on the form.  To increment a field in your SharePoint list by +1 put this code in the OnSelect property

Set(currentRecord, LookUp(your_datasource_name, ID = Value(DataCardValue_ID.Text)));
Patch(your_datasource_name,
    currentRecord,
    {IncrementFieldName: currentRecord.IncrementFieldName + 1}
);

 

#4 You might need to refresh the datasource for the change to appear in your app.  Put this code after the code above if needed.

Refresh(your_datasource_name);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Super User
Super User

Re: Update Sharepoint list by incrementing value

@PierreMichelMat 

Suggest you change this code...

First(Filter(db_name,ID="ID_of_the_record_I_want_to_update"))

 

...to this instead.  The performance of FIRST + FILTER is not great when compared to LOOKUP.

LookUp(db_name,ID="ID_of_the_record_I_want_to_update")

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Update Sharepoint list by incrementing value

@PierreMichelMat 

Being on the Detail screen will definitely make this easier. Here's how I would do it:

 

#1  Add the ID as a new field to the Detail Screen.  Do this by clicking on your form, then Edit Fields on the Right-Side properties menu.

 

#2  Make the ID field invisible because you don't actually want to show it.  Put this code the in Visible property of the datacard.

false

 

#3  Place a new button on the form.  To increment a field in your SharePoint list by +1 put this code in the OnSelect property

Set(currentRecord, LookUp(your_datasource_name, ID = Value(DataCardValue_ID.Text)));
Patch(your_datasource_name,
    currentRecord,
    {IncrementFieldName: currentRecord.IncrementFieldName + 1}
);

 

#4 You might need to refresh the datasource for the change to appear in your app.  Put this code after the code above if needed.

Refresh(your_datasource_name);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

PierreMichelMat
Regular Visitor

Re: Update Sharepoint list by incrementing value

@mdevaney  

Thanks for your reply!

Indeed it worked out perfectly well.

I just had some trouble to select the right record I wanted to update. 

I manage to do so using First(Filter(db_name,ID="ID_of_the_record_I_want_to_update"))

Maybe that's not the best way to access the record to be updated but it works!

 

Thanks for your help

 

best Regards,

Super User
Super User

Re: Update Sharepoint list by incrementing value

@PierreMichelMat 

Suggest you change this code...

First(Filter(db_name,ID="ID_of_the_record_I_want_to_update"))

 

...to this instead.  The performance of FIRST + FILTER is not great when compared to LOOKUP.

LookUp(db_name,ID="ID_of_the_record_I_want_to_update")

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

PierreMichelMat
Regular Visitor

Re: Update Sharepoint list by incrementing value

@mdevaney Thanks, way better !

Works well on my side.

Thanks again

Helpful resources

Announcements
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Power Platform 2020 release wave 1 plan

Power Platform 2020 release wave 1 plan

Features releasing from April 2020 through September 2020

Top Solution Authors
Top Kudoed Authors
Users online (9,033)