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

How to auto increment field of existing record ?

hello,

 

My app is connected with CDM datasource called "Contribution" that has field called "VoteCount" with integer type.

 

I am trying to update that field by incrementing value 1 using following formulas on button click under item area in Browse Screen:

 

Update(Contributions,ThisItem,{VoteCount:VoteCount+1})

UpdateContext({VoteCount:VoteCount+1})

Patch(Contributions,ThisItem,{VoteCount:VoteCount+1})

 

However, none of them is working out, would you please suggest what could be the issue and how can I achieve incrementing the field of existing record in pwoerapps ?

 

Thanks and Regards

1 ACCEPTED SOLUTION

Accepted Solutions
CarlosFigueira
Power Apps
Power Apps

Where is the button where you have this formula? If the button is part of the gallery template (i.e., it is replicated for all items in the gallery), then the last formula should work - within a gallery you can access the "ThisItem" operator that represents the item being shown in that row. Also, the Items property of the gallery should be either the data source 'Contribution' or a filter/search/sort formula that uses it.

 

If this is your scenario, then the last formula (Patch(Contributions,ThisItem,{VoteCount:VoteCount+1})) should work. If it doesn't, what kind of error do you get?

View solution in original post

2 REPLIES 2
CarlosFigueira
Power Apps
Power Apps

Where is the button where you have this formula? If the button is part of the gallery template (i.e., it is replicated for all items in the gallery), then the last formula should work - within a gallery you can access the "ThisItem" operator that represents the item being shown in that row. Also, the Items property of the gallery should be either the data source 'Contribution' or a filter/search/sort formula that uses it.

 

If this is your scenario, then the last formula (Patch(Contributions,ThisItem,{VoteCount:VoteCount+1})) should work. If it doesn't, what kind of error do you get?

View solution in original post

You are absolutely right 🙂 

 

I havent changed anything, however after some time following formula worked as expected among three options:

 

(Patch(Contributions,ThisItem,{VoteCount:VoteCount+1}))

 

Thank you for your time !

 

Best Regards,

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,319)