[PHP] Special characters being replaced with black diamonds with question mark �

If you ever come across this issue where special characters in your PHP wep add like aprostrophe's and ñ's are being replaced by this weird symbol, �, it could be a char-set thing.

I tried a couple of solutions but none of them worked, until I looked into my php.ini for anything related to setting the character encoding, and I found that the default_charset is set to UTF-8.

I simply changed it to ISO-8859-1, restarted the IIS server, and refreshed the page.

And it worked!

Php.ini can be found on your PHP installation folder, in my case: 
C:\Program Files (x86)\PHP\php-7.4.8\php.ini

Set default_charset to ISO-8859-1 and enable it by removing the ; in front
default_charset = "iso-8859-1"

[SQL Server] How to export table data as insert statements

In case you want to export all the rows in a table as insert statements, here's how to do it:
  1. Open MS SQL Server Management studio and login to your desired database server
  2. Right click database >> Tasks >> Generate Scripts
  3. Choose Objects: Select specific database objects >> Select the table you want to export
  4. Set scripting options: Select Save to file then click Advanced
  5. Under advanced >> General Options >> Types of data to script - choose Data only >> Click OK

  6. Proceed to next steps until table is successfully scripted, the click on Finish
And you're done, you've now exported table data as insert statements.

[PowerShell] Monitor active log files in Windows using type -wait command

Oh this is super handy. Say you have an active log file you want to monitor in real-time, simply run this command in Windows Powershell and see your logs update live on the terminal.

To demonstrate, in the screenshot above, I simply created a script that logs the current timestamp every two seconds on a logfile located at the Desktop. Then I used Powershell to monitor the updates on the terminal.

To do so, simply open Windows PowerShell on your machine and run the following command:

type -wait "logfile.txt"


[UiPath] How to setup config file and read variables

Updated December 2019
I just figured there's something wrong with my implementation of the config file, specifically its file location. The path needs to be absolute otherwise the robot package will refer to the config file inside the nupkg file and you would need to re-publish the workflow every time you update the config file.


Setting up a config file for your workflows is an efficient way to configure the initial settings of your workflow environment. Variables that refer to path locations, URLs, and other config information that you need to setup when moving your workflow from one environment to another are better placed inside a config file. Think of it as not having to go inside UiPath studio to update your variables every now and then. Instead, you can just create a config file in Ms Excel, and read it in your workflow.

Here's how:

1. Create your config file

In this example, I named the config file as FileConfig.xlsx.
You can place it anywhere actually, just take note of its absolute path. It's the only path you'll put inside your workflow.

2. Set your variables using two columns

Variable names on Column A, then values on Column B.

3. Read your config file and store it in a DataTable

Use the Read Range (Workbook) activity to read the config file and store it in a DataTable.

4. Access your config variables using the DataTable.Select method

var config_var = DataTable.Select("[Column Name]='variable name'")(0)(1).ToString

Use the select method to return the row that matches the variable name in the Var column of your config file, and (0)(1) index to refer to the second column of the first matched row. 

That's it!

If you need to add more config variables on the excel file, you should likewise add another Assign activity in your workflow to fetch the new variable.

Hope this helps!

[UIPath] How to use Regex String Matches Activity to extract capture groups

The Matches activity is a helpful way to extract parts of a string using regex patterns. If you're new to capture groups, it's essentially a regex pattern that allows you to get values in between specified characters.

For instance, this pattern "\[(.*?)\]" allows you to get all values in between square brackets.

This means that for this string example,

Email Assignment: [2574] The UK votes to leave [EU]. What's next?

there are two matches (highlighted). These two values are stored in a collection of matches with type IENumberable<Match> To get the first match, you can use: Matches(0).Value
This will get you [2574]

But if you only need the value inside the brackets, you still need to clean-up the string in order to remove the brackets.

Now, a much simpler way to extract the first match without the brackets is by using the Match.Groups method.

Using the same example above, if I use: Matches(0).Groups(1).Value
It will return just 2574

Matches(0) will return the first match: [2574]
And Groups(1) will return the first group in the match: 2574
Groups(0) on the other hand would return the whole matched string: [2574]

So essentially, Matches(0).Groups(1).Value will return the first group in the first match.
If you want to get EU instead, you should use Matches(1).Groups(1).Value

You may experiment with regex using UiPath's built in Regex Builder (Inside Matches activity, click Configure Regular Expression) or you can go to regexstorm.net/tester online.

[UiPath] Append Line not working when run using Robot or Orchestrator

My log file isn't being created when I'm running the workflow using the robot, even if the path I supplied is already its full path. But then it's working fine when it's being run using the Studio.

Create the log file first before appending to it (using the Create File activity). Normally, UiPath would automatically create the file if it doesn't exist, and then append some line. But for some reason when it's UiPath Robot doing the activity, the file doesn't get created, so UiPath doesn't bother writing anything.

That's it, let me know if it helps! :)

[UiPath] Helpful DataTable methods and queries for better sorting, filtering, extracting

Here are a couple of handy DataTable.Select queries that I found useful in managing data tables. I have previously discussed about How to filter multiple dynamic values in a datatable column but this time I'm going to collect my most used ones for future reference. I found this VB.net methods extremely helpful in minimizing the amount of Activities in my Workflow. Also, sometimes the Filter DataTable Wizard doesn't work and I found these methods more accurate.

How to select distinct/unique values in a column

OutputDT = DataTable.DefaultView.ToTable(true,"ColumnName")

Returns a datatable with distinct values from a specific column. This is similar to running a Remove Duplicate Rows activity except you can directly specify which column to affect.

How to rename DataTable column name

DataTable.Columns(4).ColumnName = "New Column Name"

Renames the 3rd column with the value specified in "New Column Name"

How to sort DataTable using multiple columns

DataTable = (From x In DataTable.AsEnumerable() Order By convert.Tostring(x("ColumnName1")), convert.ToString(x("ColumnName2")) Select x).CopyToDataTable

Returns a data table sorted in ascending order by 2 columns. This is similar to running a Sort Data Table activity except that you can use multiple sorting columns.

How to query your DataTable using Select method

OutputDT = DataTable.Select("[Column Name] IN ('Value1', 'Value2', 'Value3')").CopyToDataTable

This will return rows where the specified column contains the indicated values. Similar to filtering a table from Excel.

How to convert a DataTable column to a String Array

StringArray = (From row In DataTable.AsEnumerable() Select Convert.Tostring(row(“Column Name”))).ToArray()

This returns a String array containing all values in a given column

RelatedHow to filter multiple dynamic values in a datatable column

Just a few so far but will add to these as I go along learning UiPath better! :)