Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Patch last record on CDS

Hi, my question is very simple, but I could not find anything helpful. I would like to patch the last record that has a blank field in my CDS entity. The scenario is this: I have several records with the same value in a field (let's say fieldA) and I want to write to an another field (fieldB) only on the most recent one. Consider that the field I mentioned are all the equals, what changes is the creation date. How can I achieve that? The Last function is not delegable, so it doesn't always do what I want (almost never). 

Dual Super User III
Dual Super User III

Hi @mark6 


You can try using the formula:
Patch(DataSource, First(Sort(Filter(DataSource, Field1 = "<<ValueToMatch>>"),'Modified On',Descending)),{Field2:"<<valueToUpdate>>"})
Here, please replace DataSource with your actual Data Source name and you can get the last updated record, using OOTB attibute "Modified On".
Hope this Helps!
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Hi  ,

thanks for your answer. I tried your formula but the behaviour is always the same. The strange thing is that on my computer it does work, but when I execute on my device (Samsung tablet) it doesn't work. In particular it patches another record, the first one, not the latest. I cannot figurate why. I inserted a Refresh(entity) before the operation but the problem still remains. Any other suggestion?

Helpful resources

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Users online (11,370)