The following is a collection of quick tips and tricks for PAD . Most of these do not require a lengthy explanation, and are meant more as a quick overview, for miscellaneous.
Name | Note | Link |
Variables properties | Some variables have properties that can be used for different purposes. | Data type properties – Power Automate | Microsoft Learn |
Pagination on websites | Example of KY, see section 1. Pagination | KY – Municipal Service System – RPA Help |
Debugging | See section 4. Debugging, for a possibly longer example of creating your own debugging for PAD that is GDPR compliant. | Code structure – RPA Help |
1. Variables #
1.1 Empty/blank variable #
To create an empty variable or match on one, you must insert %”% which is translated to empty.
1.2 Data type properties #
Some data types have properties associated with them that can be used for different purposes. As an example below, we make a count of the number of items in a list and in a datatable , which tells how many items there are in each.
1.3 I Selector (custom selectors) #
If you want to use variables in your selectors, you can insert them directly into the selector, but they will not work.
If you open Text editor , insert the variable where it should be used, and then press Save , it works.
Please note that if you change the selector back to tree view, the variable will not work.
1.4 Custom object (variables with multiple values) #
For example, when filling out forms, you may end up having many extra variables that are only used for this one purpose. In such cases, you can create a custom object to contain these. This can help with readability by reducing the amount of variables you need to be able to see what they are used for and or come from.
Creating a custom object is in the format %{‘Navn’:’value’}% which is comma separated if multiple values are needed.
It will look like this when it is run.
If you need to retrieve individual variables, it can be done as follows.
1.5 Number format – American to Danish #
American number formats can be tricky sometimes when calculating amounts. Below is a quick solution on how to convert an American number format to a Danish number format.
The example will also work if there is no occurrence of a comma, for example 23.50
1.6 Check Lower/Upper Case and Numeric #
The following example checks one given character at a time whether it is a number or not, and builds a list at Run-Time for later use in a Send Keys action.
Here we follow a different approach using Regular Expressions instead, which checks whether the letter is uppercase or lowercase. At the same time, for our Send Key to work, all the letters between {} must be uppercase.
Here is a full example that checks for both numeric and case-sensitive letters.
1.7 Convert text to decimal #
Power Automate Desktop uses English format for numbers, which means that periods are used instead of commas, and vice versa.
Before converting, the text must be prepared. In a Replace text you can search for a period and replace with nothing ( %””% ), and then search for a comma and convert to a period. Once this is done, you can do a Convert text to number , which then converts the text to a decimal. If you need to convert it to Danish format later, to insert it somewhere again, you must do a replace text period with comma.
2. Logic #
2.1 Boolean expressions #
You can use booleans in if and else actions that check for multiple requirements. The Second Operand must be set to either true or false as shown in the example below.
Please note that in Power Automate, strings must be written as ‘ ‘.
Boolean expression | Power Automate |
Lie with | = |
Greater than | equal to | > |> = |
Less than | equal to | < |< = |
Not equal to | <> |
Or | OR |
And | SPIRIT |
Blank / Empty | %”% | ” |
Threaten | %true% |
False | %false% |
Contains* | Contains(VAR,’Value’,False) |
NotContains* | NotContains(VAR,’Value’,False) |
IsEmpty | IsEmpty(VAR) |
IsNotEmpty | IsNotEmpty(VAR) |
StartsWith* | StartsWith(VAR,’Value’,False) |
NotStartsWith* | NotStartsWith(VAR,’Value’,False) |
EndsWith* | EndsWith(VAR,’Value’,False) |
NotEndsWith* | NotEndsWith(VAR,’Value’,False) |
* Please note that the False value is about case-sensitivity (false = sensitive, true = ignore case), and if omitted it will ignore case by default .
Example
2.2 Switch Case #
A Switch can be considered as a menu, and Cases can be considered as points in it, which are selected depending on what the input is to the Switch . It is an alternative to long if elseif codes, where a robot has to match each individual line. In a switch case we match cases once, and therefore these work extremely quickly, and can sometimes replace long complicated calculations. A simple example could be to have a month number converted into the name ( can be used to save files as part of the name and the like ) . You also have the option of creating a Default Case which is used if none of the other cases match.
A more advanced example could be calculating which cell in an Excel sheet an amount should be put into, depending on which month it belongs to financially. In Cases you can create new Switches with new Cases , so it is an easy and fast way to do this kind of calculations. The 4 Set Variables here should represent something you have obtained elsewhere in your process, for example in a loop that calculates which row in Excel we have reached.
3. Code library / Desktop Flow templates #
Due to the way solutions are built, it is possible to create a code library, similar to a User Library , for those who have had Softomotive’s ProcessRobot . If you have code that you reuse a lot, you can create it as your own desktop flow , and call this in your other desktop flows in which the code will be used. This can be anything from uploading to an ESDH system, to code that can validate a CPR number, etc. By doing it this way, you only have to change the code in one place when there are changes.
In the example below, we have a simple desktop flow that receives an input variable in the form of a string (at the time of writing it is not possible to choose a DateTime) , and generates an output variable with the name of the month for the date being checked.
In our new desktop flow , where we want to use this functionality, we simply need to create a Run desktop flow action, and select our desktop flow , and feed it an input variable. Please note that the data type of the input variable must be the same as that set previously, in this case a string .
In relation to the collection of them, I have chosen to store them all in a separate solution, and give those that can be run as Desktop Flow a Tmp prefix, so that they can be found in the drop-down menu.
4. Web automation – Pagination #
To extract data from websites, you can either use Recorder or insert an Extract data from web page , and open the website in question while the popup window in PAD is open in the latter case.
If you move the mouse over elements on the page, they will be marked in red. If you right-click, you will be given the option to extract data. With tables, you will typically be given the option to extract the entire table. If you only want specific columns, you can extract the value from the top row of the column, and then extract the value to the one below, after which PAD will extract the rest of the column itself.
If there are multiple pages of data, you can right-click on the button that brings up the next page and select Set element as pager . When the robot runs and extracts data, it will subsequently press Next itself in the example, and extract data and add to previous extractions.
When you are finished, press Finish . If you have used Recorder, you will now have all the actions you have made inserted, as well as an Extract data from web page action.
5. Send Keys #
It is possible in Send Key actions to insert how many times you want a click, by inserting a colon and number afterwards, rather than having to paste for each identical key. If you press multiple buttons simultaneously, it is in the last one that the number must be inserted (example {Alt({Tab:5} ) ).
6. Copy-Paste code via text #
It’s easy to copy-paste code back and forth between Desktop Flows within yourself. If you need to share with others, you can copy-paste your code into a notepad and send the contents to someone else. They can copy-paste this and insert it directly into their own Desktop Flow , and it should import the correct filled-in actions.
This is an example of calculating last quarter based on today’s date.
The following is the code in plain text, which can be imported by others directly into a Desktop Flow .
“
DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateOnly CurrentDateTime=> DateCurrent
SET QtYearCurrent TO 1 / 3 – 1
Variables.TruncateNumber.GetIntegerPart Number: QtYearCurrent Result=> QtYearCurrent
IF QtYearCurrent = 0 THEN
SET QtYearCurrent TO 4
THAN
“
7. Copilot help with scripts #
For various script actions ( VBScript, Powershell, SQL etc ) you can use Copilot and submit a prompt that returns a usable script.