FlowChart Decision Condition

I am developing a flow in UiPath and I have an activity in UiPath to export data from DB which is what I am using and in my workflow chart, I want to add a decision to confirm if there is data on the table I want to export. How do I write the condition to satisfy the decision? What is the format I am supposed to use? Please help.

@Baba_Karim_Abdulai

First use a select sttement to check if db table has data it would return a dtataable can get dt.Rowcount

Cheers

I am new to RPA so I want to know if the select statement is an activity?

@Baba_Karim_Abdulai ,

you can try this:

In UiPath, when you want to add a decision to check if there is data in a table before proceeding with further activities like exporting it, you’ll typically use a “Decision” activity (often represented as a diamond shape in flowcharts). Here’s a general guide on how to implement this:

Steps to Add a Decision to Check for Data in a Table

  1. Retrieve Your Data:
    First, ensure you have already queried the database and stored the result in a variable. This variable usually would be a DataTable, for example:

    myDataTable
    
  2. Add a Decision Activity:
    Drag the Decision activity into your workflow where you want to check for the data.

  3. Define the Condition:
    In the properties of the Decision activity, you will need to set the condition that checks whether the DataTable contains any rows.

    The condition you can use is:

    myDataTable.Rows.Count > 0
    

    This condition checks if the number of rows in the DataTable is greater than zero (indicating that there is data available).

  4. Outcome Paths:

    • True Path (Data Exists): If the condition is true (data exists), you can proceed with the export activity or any follow-up actions.
    • False Path (No Data): If the condition is false (no data in the DataTable), you can decide to log an information message, throw an exception, or skip the export process.

Example Workflow Structure

Here’s how your flow might look:

  1. Get Data from DB (activity that fills myDataTable)
  2. Decision Activity: Check for data
    • Condition: myDataTable.Rows.Count > 0
    • True Path: Proceed with the export
    • False Path: Log “No data to export” or notify the user

Additional Tips

  • Ensure that myDataTable is properly initialized and populated before it reaches the Decision activity.
  • You might also want to include error handling in case the query fails or produces an unexpected result.
  • Use logging activities to capture outcomes, especially if no data is found, which can be helpful for debugging purposes.
1 Like

@Baba_Karim_Abdulai

In the context of RPA (Robotic Process Automation) using UiPath, a SELECT statement is not an activity itself; rather, it is part of the SQL language used to query databases. When you work with databases in UiPath, you typically use activities that allow you to execute SQL queries, which may include SELECT statements.

Working with SQL in UiPath

To execute SQL queries in UiPath, you generally use the following activities:

  1. Connect:

    • Activity: Connect
    • Purpose: This activity establishes a connection to a database using connection strings.
    • Example: You set up the database connection parameters (like server name, database name, authentication method, etc.).
  2. Execute Query:

    • Activity: Execute Query
    • Purpose: This activity is used to execute a SQL SELECT statement or any other SQL command that returns data.
    • Usage: You specify your SELECT statement in the SQL property of this activity along with the connection established in the Connect activity.
    • Output: It typically outputs the result into a variable of type DataTable, which you can later process in your workflow.
    SELECT * FROM YourTableName
    
  3. Execute Non Query:

    • Activity: Execute Non Query
    • Purpose: This activity is used for executing SQL commands that do not return data (like INSERT, UPDATE, DELETE).

Example Workflow

Here’s a basic outline of how you can use these activities in a UiPath workflow to execute a SELECT statement:

  1. Connect to the database:

    • Use the Connect activity to create a connection to your database, specifying the connection string details.
  2. Execute Query:

    • Use the Execute Query activity:
      • Set the SQL property to your SELECT statement (e.g., SELECT * FROM YourTableName).
      • Set the output property to a DataTable variable (e.g., resultDataTable).
  3. Process the Result:

    • Use activities to check the contents of resultDataTable, such as checking the number of rows or iterating through the records.

Sample SELECT Statement in UiPath

Here’s how it could look in the properties of the Execute Query activity:

  • SQL: SELECT * FROM Employees
  • Connection: yourDbConnectionVariable
  • Output: resultDataTable

Conclusion

To summarize, while a SELECT statement itself is not an activity in UiPath, executing a SELECT statement is done through activities like Execute Query, which allows you to run your SQL commands and retrieve data from a database.

1 Like