Intro

Buttons, Excel, Approvals and notification in Power Automate. Tracking a starting and end point into Excel, by triggering a button. This is a flow that I will talk about today!

The solution will have two Flow’s that could be triggered by a button. The values will be added to an excel file that is stored on OneDrive for Business. By registering the starting point with address, start date, start time and also the information of end point. I could calculated travel times between the start and end point.

Work Less Do More

How-to?

We have created a n Excel file that looks like this and contains followzing headers: StartAddress, StartDate, StartTime, EndAddress, EndDate and EndTime. __PowerAddId__ is used to create a unique id of the tracking line.

Excel headers

Using two MS Flow buttons to register the start and end point, including some checks to verify the current tracking status of the Flow.

Button: Start Travel Tracking

Overview flow:

Trigger flow by a button “Start Travel Tracking”

Format Date – formatDateTime(triggerOutputs()[‘headers’][‘x-ms-user-timestamp’],’yyyyMMdd’)

Format Time- convertFromUtc(triggerOutputs()[‘headers’][‘x-ms-user-timestamp’],’Romance Standard Time’,’HH:mm’)
Adjust time to CET time.

Important 

User Get Rows (Excel for Business), using this will not lock the file and after getting the rows you are not able to add or change fields in the Excel file.

Getting the rows of an XLS file that is located on the OneDrive for Business.

Getting the last row of the Excel file

Getting the last row of the Excel file, by using following expression: last(body(‘Get_Rows’)?[‘value’])

Creating an Array of the last row: array(Outputs(‘Last_Row_Excel’))

Add an Apply to each for the outputs of Array Last Row Excel

Yes/No

In the condition we check if the Start and End Date has been filled in, when filled in we need to add a new row, else we notify that the travel tracking was already started and not been ended correctly.

[YES]

StartDate: Outputs[‘Format_Date’]
StartTime: Outputs[‘Format_Time’]
__PowerAppsID__: triggerOutputs()[‘headers][‘x-ms-user-timestamp’]

Mobile notification

[No]

Approval notification will be sent to the mobile app, for the question [Stop Travel Tracking?]

[YES]

Format Time End: convertFromUtc(body(‘Current_Time’),’Romance Standard Time’,’HH:mm’)
Convert to CET Time

Last Row Excel End è last(body(‘Get_Rows_End’)?[‘value’])

Array Last row Excel End è array(outputs(‘Last_Row_Excel_End’))

[NO]

Do nothing

Second Button – STOP TRAVEL TRACKING

Overview Flow:

Format Date: formatDateTime(triggerOutputs()[‘headers’][‘x-ms-user-timestamp’],’yyyyMMdd’)
Format Time to West Europe (CET): convertFromUtc(triggerOutputs()[‘headers’][‘x-ms-user-timestamp’],’RomanceStandard Time’,’HH:mm’)

Get last row of the Excel file

Last Row Excel:  last(body(‘Get_Rows’)?[‘value’])
Array Last Row Excel: array(outputs(‘Last_Row_Excel’))

[YES]

When the End Date has been already filled in we notify by sending a notification towards the Microsoft Flow app.

Enjoy! Feedback is welcome

Like, Share! 
Would you like more of these Flow examples? Suggestions are welcome ...

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: