Can you explain the log file part where you just store diagnostics? What is that?? Can you also share a SS if possible?
Simple example:
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
Text.ConvertDateTimeToText.FromDateTime DateTime: CurrentDateTime StandardFormat: Text.WellKnownDateTimeFormat.SortableDateTime Result=> FormattedDateTime
Text.Replace Text: FormattedDateTime TextToFind: $''':''' IsRegEx: False IgnoreCase: False ReplaceWith: $'''.''' ActivateEscapeSequences: False Result=> FormattedDateTime
SET LogFile TO $'''C:\\Users\\SECRETUSER\\Desktop\\%FormattedDateTime%.log'''
File.WriteText File: LogFile TextToWrite: $'''Flow Start: %CurrentDateTime%
-----''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
File.WriteText File: LogFile TextToWrite: $'''Starting browser''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
WebAutomation.LaunchEdge.LaunchEdge Url: $'''mediamarkt.pl/rtv-i-telewizory/telewizory/wszystkie-telewizory?limit=50&page=1''' WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 BrowserInstance=> Browser
ON ERROR REPEAT 1 TIMES WAIT 5
END
File.WriteText File: LogFile TextToWrite: $'''Browser started''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
File.WriteText File: LogFile TextToWrite: $'''Extractign data''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
WebAutomation.ExtractData.ExtractList BrowserInstance: Browser Control: $'''html > body > div:eq(0) > div:eq(1) > div:eq(3) > div > div > div:eq(5) > div:eq(1) > div:eq(2) > div:eq(0) > div''' ExtractionParameters: {[$'''div:eq(0) > div:eq(0) > div:eq(0) > div:eq(0) > a > h2''', $'''Own Text''', $''''''] } PostProcessData: False TimeoutInSeconds: 60 ExtractedData=> DataFromWebPage
File.WriteText File: LogFile TextToWrite: $'''Starting loop''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
SET Counter TO 0
LOOP FOREACH CurrentItem IN DataFromWebPage
Variables.IncreaseVariable Value: Counter IncrementValue: 1
File.WriteText File: LogFile TextToWrite: $'''Item no %Counter% out of %DataFromWebPage.RowsCount%: %CurrentItem%''' AppendNewLine: True IfFileExists: File.IfFileExists.Append Encoding: File.FileEncoding.Unicode
END
For the logging part I was thinking, where ever I have an important action in my flow, I will be making an api call after that action. In the body of the api call, I will take the variable I am sending to the above action, which can be called as the input for that action and the output variable that will be coming from that action directly, I will send it as the output of the file. So, thats how I was thinking to log data. And for the errors, I will run a subflow to store the inputs and log it and end that iteration and send it to next iteration.
Sounds bit complicated but it really depends what you want to achieve, I store those logs to see some verbose info in case flows fail. But you can call api, store in DB, store in file, excel etc.
One more question for everyone. With machines, can I do this, lets say I have 50 files on 1st machine and 50 files on second and so on. And at the same time on all machines the flow runs and processing of all the files is done. This might improve the performance, if I am understanding the concept of machines right.
You can call another flow from within one flow but it executes on the same machine, it is treated as any other action. So you would need to have those files on network share for example, then trigger X flows on X machine handling those files, just need to build the mechanism so they don't interfere with each other (such as 1 bot handles 1 file or locks the file so other don't grab it etc).
And is there parent and child flows in desktop flows? Probably was thinking to use same subflows for many other flows as we can just copy all the actions and paste it in other flow.
Yes, how I use this:
1. I split individual Desktop Flows in Sub flows and treat each subflow kind of a function in programming - it does specific task it was created for.
2. Then if I have a Subflow that I know i will be using in other flows, I save it as a separate Desktop flow, configure input pramateres etc.
3. I call this Desktop flow from any other flow.
Example for this is launching web browser or desktop app and logging in with credentials.
Whenever logon process changes, you need to update this one desktop flow only and and other Desktop flows that call it will work as expected. Again, I am treating some of my flows as a functions that are called by other desktop flows.
One issue with those is that they appear in Power Automate web as if they were any other flows/bots, so kind of clutter the logs, but If you name them like "Shared_Web_App_X_Logon" you see it is not the full bot, but shared one.
And I read an article today, in which person had mentioned all the flow runs get stored in dataverse in flow sessions table. But when I opened that table, it was last modified last month.
Flows that you trigger from Power Automate or console are stored in dataverse.
Runs that you start in Designer do not store in dataverse.
Having said that, remember that all variables (including your secret data if you read it from file/page etc into variable) are stored in logs and they land in the cloud. To prevent that mark variable as a sensitive variable - this will replace the actual value before it sends the log to the cloud.
For the sake of making it habit, I mark all of my variables sensitive 😄
https://learn.microsoft.com/en-us/power-automate/desktop-flows/manage-variables#sensitive-variables
I have no idea about the flows getting stored in dataverse. Can you guys share articles or videos regarding that?
Main issues I had to resolve when it comes to logs in the cloud:
1. Use sensitive variables so secret data does not go to cloud
2. When capturing app/web UI hide secret data behind the recording window - screenshot of the entire windows lands in cloud, so if you have sensitive data - it is an issue
3. Power Automate flow logs are stored for 28 days, Power Automate Desktop logs are stored as long as the flow exists in the Environment - for this reason I have a cloud flows that runs each day and removes logs older than 14 days
Edit:
Forgot to add:
When your desktop flow fail, it captures the screenshot of entire desktop and sends to the cloud.
Again, if you had app or web opened with sensitive information - it lands in cloud.
I manage this in my Main error handling:
If something goes wrong and I cannot recover with error handlign in subflows or loops etc. main error handling calls a subflow names "CleanFail" 😄 where i ensure I close all of the apps, web pages, anything that can display sensitive information then I open empty notepad in full screen that covers entire desktop in case anything is still open that could be displaying any data.
To sum this up - you can build flows that will limit the sensitive data leak from your on-prem to the minimum if not completely.
Key points:
- Sensitive variables
- Secure Inputs/Outputs in PA and PAD
- No sensitive data displayed in UI/Web or hidden behind record window so they don't get captured on screenshot
- Error handling that manages failing flow, so it does not ends up unmanaged fail
I hope this helps