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

SharePoint Get items - Newest list values

I am creating an approval flow that operates when a list item is created (Time Off Request).  This is a request for time off (Vacation/Sick/etc.).  This all works.

 

I am trying to add functionality so I can see the amount of vacation or sick hours employees have in the approval.  So, I thought I would create another list (Vacation/Sick) that has a date and the amount of hours for vacation and sick.  This way the employee can view their hours as well.

 

My goal is to subtract the amount of hours requested from the amount of hours they have, and then update the Vacation/Sick list.   If vacation, then subtract the field “total hours” (number field) from the Time Off Request form from the total vacation hours or total sick hours depending on the Vacation/Sick hour list and then update the Vacation/Sick hour list with the date and the calculated total hours for vacation and sick. 

 

Then, the next time they make a request, it will pull the latest data from the vacation/sick list.  I’m having a few issues that I just can’t seem to get around.

 

Problems:

  1. I am unable to get the latest row of info from the vacation/sick list.  Using Get Item.  I have it set to Top Count of 1.  This only pulls the oldest list item.  I would like to only pull the newest list item but I don’t know how to properly filter that information.
  2. I am unable to do a calculation from two different lists.  It doesn't give me the dynamic values from the Vacation/Sick Hours field in the dynamic content. 

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @MSheriff,

 

For your first problem to get the newest list item, please refer to screenshot below to create the flow:

Capture.PNG

 

The expression in the Compose as below:

body('Get_items')?['value']?[sub(length(body('Get_items')?['value']),1)]?['ID']

The flow would run successfully to get the newest list item as below:

Capture.PNG

 

For your second problem, please share more details of your sharepoint lists columns and items? you could use workflow definition language to calculate data:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#s...

 

 

 

Best regards,

Alice

 

 

View solution in original post

2 REPLIES 2
Community Support
Community Support

Hi @MSheriff,

 

For your first problem to get the newest list item, please refer to screenshot below to create the flow:

Capture.PNG

 

The expression in the Compose as below:

body('Get_items')?['value']?[sub(length(body('Get_items')?['value']),1)]?['ID']

The flow would run successfully to get the newest list item as below:

Capture.PNG

 

For your second problem, please share more details of your sharepoint lists columns and items? you could use workflow definition language to calculate data:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#s...

 

 

 

Best regards,

Alice

 

 

View solution in original post

It worked!  Thank you.  

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Top Kudoed Authors
Users online (7,832)