A repository of notes about Performance Testing, Automation, RPA, and Web Design.

  • UiPath

    Show all posts related to UiPath

  • Windows

    Show all posts related to Windows

  • Web Design

    Show all posts related to Web Design

Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

[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

Another example for creating log files where date and time is part of the filename

var logs = DataTable.Select("[Var]='filepath_logs'")(0)(1).ToString + Now.Date.ToString("yyyy-MM-dd-") + DateTime.Now.ToString("HHmmss") + ".txt"

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

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!
Share:

[UiPath] How to create Windows user input form using SyForms form designer (IsClosingForm hotfix)

Here's an entry on how to use the SyForms Form Designer package on UiPath which is incredibly helpful in getting user input using a Windows form.

This answers questions on:
✔ How to accept date input from user and
✔ How to accept multiple inputs from user using just one form


But first, a little info on this package:

SyForms is a custom activity developed by Florent Salendres of Symphony as a hackathon entry for UIPath's Power Up Automation 2018. It won Winners Choice and UiPath Grand Prize of Excellence in RPA and is probably one of the most popular form designers from UiPath Gallery. I personally am very thankful I stumbled upon this activity because it provides better user interaction by the way of Windows forms.

Now, all the official documentation you need is here: https://go.uipath.com/component/syforms-uipath-forms-designer
https://devpost.com/software/uipath-form-designer
https://forum.uipath.com/t/syforms-uipath-forms-designer/63539/29

But for the purpose of documenting a how to guide, here's how to use the package and create a simple form that accepts date and text input.

I'm using UiPath Community Edition version 19.8.0

Step 1: Download and install the package

You have two options, you can either download it from the Gallery


OR you can download the hotfix version from this link which addresses the issue of the form not closing upon clicking the submit button (even if the property IsClosingForm is set to True).

If you chose the hotfix version, here's how to install it:

  1. As mentioned above, download hotfix from this link
  2. Save the .nupkg package file under C:\Users\username\AppData\Local\UiPath\app-19.8.0\Packages (or wherever your Packages folder is)
  3. Update the path with the appropriate username and app version folder, in red.
  4. Go back to UiPath Manage Packages and navigate to Local. Symphony should appear.
  5. Install and Save



Step 2: Create a new process and add the activity Show Form

Found under Symphony >> Extensions >> SyForms >> Show Form



Step 3: Create a new form

  1. Click on New
  2. Enter form name
  3. Click OK
  4. It will create a json file. Select it from the dropdown and click Design
Step 4: Design the form

We'll be creating a simple form that accepts Name and Birthday. The designer is pretty straightforward, just click on the type of control you want from the toolbar and position it on the form window.


Step 5: Expose your input arguments

For all your input fields, make sure to set ExposeAsArgument property to True as seen in the above photo. This automatically creates arguments for your fields so that you can access the value later on.


The next thing to do after exposing your arguments is to create Assign To variables to it. I named the 2 variables as var_name and var_bday and set the variable type to Control (System.Windows.Forms.Control).

For the Submit button, you should also set the IsClosingForm property to True so that the form window will close after you click on Submit.

Step 5: Access your input data

Finally, you can access your input data by using the Text property of the Control variable.

var_name.Text
var_bday.Text

Let's try to output it using a message box.

Here's the output:


For the date, you can play around with the text value to output different date formats using the Convert.ToDateTime() and ToString() System methods.

ie.
Convert.ToDateTime(var_bday.Text).ToString("yyyy-MM-dd")
will output the following:


For more DateTime formats and helpful string manipulation techniques, check out:

That's it! Let me know if it works. :)
Share: