UiPath Coded Automation: Revolutionizing the Future of Robotic Process Automation (RPA)

Create reusable coded workflows or coded test cases instead of low-code activities

Satish Prasad
16 Min Read

Introduction to UiPath Coded Automation

In the realm of software development, the advent of low-code and no-code solutions has revolutionized the way automation is built. These innovative approaches have empowered a new breed of developers, enabling even those with limited technical expertise to create powerful solutions for testing and business processes, also known as Robotic Process Automation (RPA).

However, for more technically inclined testers and RPA developers, the limitations of low-code automation often pose challenges regarding flexibility, comprehension, and maintainability.

UiPath Studio is proud to present the public preview of Coded Automation to address the needs of developers who prefer to work with code.

UiPath Studio introduces Coded Automation, a feature in public preview, to cater to developers with solid coding backgrounds.

Coded Automation provides flexibility and customization, empowering technical practitioners to create sophisticated automation.

It streamlines maintenance and collaboration through integration with version control systems and IDEs and unlocks innovation by leveraging external integrations and cutting-edge technologies.

๐Ÿš€ UiPath Studio introduces Coded Automations, a feature in public preview, targeting developers with coding backgrounds.

๐ŸŽ›๏ธ Coded Automations offer enhanced flexibility, allowing developers to tailor automations to their specific requirements.

๐Ÿ’ช Coded Automations empower technical practitioners, such as skilled testers and seasoned RPA developers, to create sophisticated automations using their coding knowledge.

๐Ÿ‘ฅ Coded Automations simplify maintenance and collaboration through integration with version control systems, IDEs, and collaboration tools.

๐Ÿ”“ Coded Automations unlock innovation by leveraging external integrations, cutting-edge technologies, and emerging trends.

How to Get Started with Coded Automation

The 23.6 Community release introduces an exciting feature called Coded Automation, which is now available as a Public Preview. This article will guide you through the process of getting started with Coded Automation and explore the various file types you can create.

Prerequisites

  • Install UiPath Studio 2023.6.
  • Install the versions of the activity packages, also known as services, supported in coded automation:
    • System.Activities 23.6-preview
    • UiAutomation.Activities 23.6-preview
    • Testing.Activities 23.6-preview

Creating a New Project

To begin, you need to create a new Modern or Portable project. Both Visual Basic (VB) and C# are supported as workflow expression languages, providing you with flexibility in your development process.

Introducing the File Types

Once you have created your project, you can proceed to create three new types of files within the Coded Automation framework. Each file type serves a specific purpose and offers unique functionalities.

How to Get Started with Coded Automation
How to Get Started with Coded Automation

1. Coded Workflows

Coded Workflows are not only equivalent to Sequences but also serve as entry points for your automation projects. For instance, the Main.xaml file in a new empty process project can be considered a Coded Workflow. It’s important to note that Coded Workflows can be set as the Main entry point as well. To invoke a Coded Workflow, you can use the Invoke Workflow File activity just like any other XAML file.

2. Coded Test Cases

Coded Test Cases, as the name suggests, are equivalent to Test Cases. They allow you to define and execute tests for your automation processes. With Coded Test Cases, you can ensure the reliability and accuracy of your automated workflows.

3. Code Source Files

Code Source Files represent files that contain source code. They serve a purpose similar to non-entry points XAML files, such as utility files or XAMLs that implement a part of the business logic. The code within source code files can be directly called in expressions inside XAML files, enabling seamless integration and flexibility. Additionally, you can use source code files to define more specific types of variables or arguments.

Working with Coded automations

๐Ÿ› ๏ธ Debugging: Debug-coded automation using breakpoints, debugging panels, and profile execution. Troubleshoot execution flow with debug running mode.

โ–ถ๏ธ Running: Run coded automation in Studio’s Design tab by clicking “Run” for the whole project or “Run File” for the current file.

๐Ÿ” Validation: Use Workflow Analyzer to check for inconsistencies and view errors, warnings, and messages for both XAML (low-code automation) and CS files (coded automation).

๐Ÿ“ฆ Publishing: Publish a Studio project to Orchestrator, custom NuGet feed, or locally. Exclude test cases by selecting “Ignore from Publish” for specific files in the Project panel.

๐Ÿค– Supported Runtimes: Deploy coded automation on Robots supporting Windows framework versions 2022.4 and higher, and any supported version of Orchestrator.

ย 

Whats features do we have in Studio Code editor?

The Studio code editor interface facilitates efficient automation of project management, navigation, editing, and versioning. Key components include:

๐Ÿ”ง Code Editor: Displaying the current automation project, enabling changes, and highlighting errors. It functions like a standard code editor tool.

๐Ÿ“‹ Context Menu: Accessible by right-clicking a line in coded automation, offering actions with keyboard shortcuts. Examples include Quick Actions, Rename, Go to Definition, Toggle Breakpoint, Find All References, Format Document, Comment, Uncomment, Cut, Copy, Paste, and Delete.

๐Ÿ—‚๏ธ Tabs: Files open with tabs in the editor’s header for easy navigation and management.

๐Ÿ” Breadcrumbs: Available in the code editor header to navigate classes and methods within a file.

๐Ÿ”„ Versioning: Coded Automation projects can be versioned using semantic (Major.Minor.Patch[-Suffix]) or legacy (M.m.bbbb.rrrrr) versioning schemes. Projects can be versioned when published to Orchestrator or using source control systems like GIT, TFS, or SVN.

Creating your first UiPath-coded workflow

            using UiPath.CodedWorkflows;

namespace CodedAndLowCodeWorkflow
{
    public class _00_FirstCodedWorkflow : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {
            Log("Hello World from Coded Workflows!");
        }
    }
}
        
  1. The code starts with the using directive using UiPath.CodedWorkflows;, which imports the necessary classes and functionalities from the UiPath.CodedWorkflows namespace.

  2. The code defines a namespace CodedAndLowCodeWorkflow.

  3. Within the namespace, a public class named _00_FirstCodedWorkflow is declared. This class inherits from CodedWorkflow, indicating that it is intended for coded workflows in UiPath.

  4. Inside the _00_FirstCodedWorkflow class, there is a single method named Execute(), which is decorated with the [Workflow] attribute. This attribute is specific to UiPath coded workflows and marks the method as the entry point for the workflow.

Let’s Deep Dive – Createย  More Complex Examples slowly!

UiPath Coded Automation: Revolutionizing the Future of Robotic Process Automation (RPA) 6
            using System.Windows.Forms;
using UiPath.CodedWorkflows;
using UiPath.Core.Activities;

namespace CodedAndLowCodeWorkflow
{
    public class _01_CodedWorkflowExample : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {
            // 1. Open Application 
            var ACMESite = uiAutomation.Open("LogIn");

            // 2. Get Assets from Orch.
            Log("Reading UserName & Password from UiPath Orch Assets...");
            var credential = system.GetCredential("ACME_Credential", null, out var password, CacheStrategyEnum.None, 30000);

            // 3. Type Into UserName
            ACMESite.TypeInto("Email", credential);

            // 4. Type Into password
            var actualPassword = new System.Net.NetworkCredential(string.Empty, password).Password;
            ACMESite.TypeInto("Password", actualPassword);

            // 5. Click the Submit button to perform the Login
            ACMESite.Click("Login");

            //6. Check if Screen Changed
            var dashboard = uiAutomation.Attach("Dashboard");
            var Description = dashboard.GetText("User options");

            // 6. Display Message 
            Log("Dashboard Appeared..");

        }
    }
}
        

Creating hybrid automation – Combining Coded and Low-code Workflows

ย 

Explore multiple ways of building hybrid automation by combining low-code automation with coded automation. The following scenarios will be covered:

๐Ÿ”„ Invoking a coded source file from a low-code workflowย 

โš™๏ธ Leveraging coded automation within a low-code workflow with argumentsย 

๐Ÿ”„ Invoking one coded automation from anotherย 

๐Ÿ”„ Integrating a low-code workflow into coded automationย 

ย 

Invoke Coded Workflow File in LowCode Workflow fileย 

You can invoke coded workflow in .xaml file the same way as you do invoke other xaml files.

PS – Arguments will not come automatically you might need to add them manually.

UiPath Coded Automation: Revolutionizing the Future of Robotic Process Automation (RPA) 7

Invoke Coded Automation workflow inside Another Coded Automation workflow

ย 

The RunWorkflow method is called to execute another workflow, specified in “03_CodedWorkflowWithArguments.cs.” This method takes two arguments:

  • The filename of the workflow to run (as a string).
  • A dictionary containing input arguments to pass to the executed workflow.

The input arguments are defined in the dictionary:

  • “assetName”: This argument is set to “MyAsset” and represents the name of the asset to be used in the executed workflow.
  • “assetValue”: This argument is set to “hello world” and represents the value to be assigned to the “MyAsset” asset.

The RunWorkflow the method returns a dictionary containing the result of the executed workflow.

            using System.Collections.Generic;
using UiPath.CodedWorkflows;


namespace CodedAndLowCodeWorkflow
{
    public class _04_CodedWorkFlowUsingCodedWorkFlow : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {
            // Requirements:
            // - Create an asset of type Text called MyAsset in the current folder.

            var result = RunWorkflow("03_CodedWorkflowWithArguments.cs", new Dictionary<string, object>(){
                        {"assetName", "MyAsset"},
                        {"assetValue", "hello world"}
                    });

            if ((bool)result["assetValueWasChanged"])
            {
                Log("Reset asset MyAsset, but it had a different value, previous value was " + result["assetValue"]);
            }
            else
            {
                Log("No reset was required on asset MyAsset, which had the expected value.");
            }
        }
    }
}
        

Invoke .xaml(LowCode Automation Workflow) in .cs(Coded Automation Workflow)

ย 

The RunWorkflow method is called to execute the low-code workflow named “Login.xaml”. This method takes two arguments:

  • The filename of the low-code workflow to run (as a string). In this case, it is “Login.xaml”.
  • A dictionary containing input arguments to pass to the executed low-code workflow.

The input argument is defined in the dictionary:

  • “in_AssetName”: This argument is set to “ACME_Credential” and represents the name of an asset to be used in the invoked low-code workflow.

The RunWorkflow method returns a variable result that can be used to capture the output of the low-code workflow execution. However, in this code snippet, the result variable is not utilized further.

            using System.Collections.Generic;
using UiPath.CodedWorkflows;

namespace CodedAndLowCodeWorkflow
{
    public class _05_LowCodeWorkFlowInCodedWorkflow : CodedWorkflow
    {
        [Workflow]
        public void Execute()
        {
         
            Log("Lets Invoke LowCode Workflow here..!");
            var result = RunWorkflow("Login.xaml", new Dictionary<string, object>()
              {
                {"in_AssetName", "ACME_Credential"},
              });
        }
    }
}
        

Why Choose Coded Automations Over Low-Code Solutions?

๐Ÿ’ป Coded automation offers higher productivity and flexibility, allowing developers to handle complex automation tasks with ease.

๐Ÿค Coded automation has an edge in collaboration, enabling efficient code reviews, bug fixing, and simultaneous work on different parts of the automation project.

๐Ÿ“š Coded automation provides structured and organized code, enhancing readability and maintainability compared to convoluted logic in low-code solutions.

โšก๏ธ Coded automation allows fine-tuning for optimal performance, including algorithm optimization and efficient resource utilization.

๐Ÿ“– Transitioning to coded automation is easier for developers with coding experience, leveraging existing knowledge and skills.

โญ๏ธ Developers can unlock a new level of productivity, complexity management, collaboration, reviewability, readability, and performance with coded automation.

๐Ÿš€ Coded automation empowers developers to create powerful, efficient, and customizable automation.

UiPath Coded Automation stands out from traditional RPA due to its ability to utilize coding languages like C#, VB.NET, and Python(planned for future release)ย  providing unmatched flexibility and customization. It empowers developers with advanced features, seamless integration, and improved reusability, setting it apart in the RPA landscape.

Yes, beginners can benefit from UiPath Coded Automation. While having some coding experience can be advantageous, UiPath’s extensive documentation, tutorials, and community support make it accessible to developers with varying levels of expertise.

Yes, UiPath Coded Automation supports seamless integration with third-party applications. Its compatibility with coding languages allows developers to connect with various APIs and external systems effortlessly.

Absolutely! UiPath Coded Automation can be seamlessly combined with visual automation techniques offered by UiPath Studio. This hybrid approach further extends the potential of automation, making it more versatile and adaptive.

As of NOW NO. But in the future Uiapth plans to provide extensions and library to be utilised in different leading IDE such as Visual Studio.

Conclusion:

Coded Automation in UiPath Studio represents a groundbreaking advancement in the field of test and business process automation. By catering to the needs of technical practitioners and offering a code-centric approach, UiPath empowers developers to unleash their creativity and build highly customized and efficient automation. With the ability to seamlessly integrate with existing coding practices and the freedom to innovate, Coded Automations are set to redefine the way automation solutions are created and maintained.

Experience the power of Coded automation and revolutionize your automation journey with UiPath Studio today!

Share This Article
Follow:
Hey there, I'm Satish Prasad, and I've got a Master's Degree (MCA) from NIT Kurukshetra. With over 12 years in the game, I've been diving deep into Data Analytics, Delaware House, ETL, Production Support, Robotic Process Automation (RPA), and Intelligent Automation. I've hopped around various IT firms, hustling in functions like Investment Banking, Mutual Funds, Logistics, Travel, and Tourism. My jam? Building over 100 Production Bots to amp up efficiency. Let's connect! Join me in exploring the exciting realms of Data Analytics, RPA, and Intelligent Automation. It's been a wild ride, and I'm here to share insights, stories, and tech vibes that'll keep you in the loop. Catch you on the flip side
Leave a Comment