cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MSheriff
Level: Powered On

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 Team
Community Support Team

Re: SharePoint Get items - Newest list values

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 Team
Community Support Team

Re: SharePoint Get items - Newest list values

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

MSheriff
Level: Powered On

Re: SharePoint Get items - Newest list values

It worked!  Thank you.  

 

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,640)