Study guide

6.4 Invoke Method & Invoke Code Activities

UiPath Automation Developer Professional UiPath-ADPv1

Track your progress as you read

Finished sections get a check mark.

1 Chapter 1: Exam Overview & Blueprint Map

1.1 About the UiPath-ADPv1 Exam: Format, Fees & Policies 1.2 The Exam Topics Mapped to This Guide & a Study Plan

2 Chapter 2: REFramework Architecture & State Dynamics

2.1 State Machine Architecture & The Four Core States 2.2 Configuration Management: Settings, Constants, and Assets 2.3 Transaction Types & The Dispatcher vs. Performer Architecture 2.4 Adapting REFramework: Tabular Data, Collections & Linear Processes

3 Chapter 3: REFramework Exception Handling & Recovery

3.1 BusinessRuleException vs. System.Exception Handling Patterns 3.2 Retry Mechanisms: Queue Retries vs. REFramework MaxRetryNumber 3.3 Consecutive System Exceptions & Graceful Process Termination

4 Chapter 4: State Machines, Custom Log Fields & REFramework Testing

4.1 Building State Machine Projects in Studio 4.2 Logging Levels, Robot Logs & Custom Log Fields in REFramework 4.3 Testing a REFramework Project With and Without Orchestrator Queues

5 Chapter 5: LINQ Queries & DataTable Operations

5.1 LINQ Essentials for Collections & Filtering 5.2 Advanced DataTable Querying with LINQ 5.3 In-Memory DataTable Transformations & Column Operations

6 Chapter 6: Regex, DateTime, JSON & Invoke Activities

6.1 Regular Expressions & Text Parsing for Automation 6.2 DateTime Formatting, Timezone Conversions & TimeSpan Calculations 6.3 JSON Parsing, JSONPath & Serialization with Newtonsoft.Json 6.4 Invoke Method & Invoke Code Activities 6.5 Data Referencing in Invokes: DataTable, List & Dictionary Arguments

7 Chapter 7: Modern UI Automation & Unified Targeting

7.1 Modern Design Experience & The Unified Target Concept 7.2 Anchors, Relative Elements & UI Automation Activities 7.3 Dynamic Selectors, Variables & Wildcards in Selectors

8 Chapter 8: Object Repository, Computer Vision & Remote Runtime

8.1 Object Repository & UI Descriptor Libraries 8.2 AI Computer Vision for Unattended & Remote Interfaces 8.3 Automation in Virtual Environments & UiPath Remote Runtime

9 Chapter 9: Advanced UI Automation: Browser Modes, Agentic UI & macOS

9.1 Browser Automation with the WebDriver Protocol 9.2 Agentic UI Automation: ScreenPlay, Semantic Activities & Healing Agent 9.3 macOS Automation: Native Apps, Office Apps & AppleScript

10 Chapter 10: Advanced Control Flow & Exception Architecture

10.1 Flowcharts, Sequences & Parallel Control Flow Patterns 10.2 Global Exception Handler Architecture & ErrorAction Directives 10.3 TryCatch, Retry Scope & Custom Exception Architectures

11 Chapter 11: Orchestrator Queues & Transaction Management

11.1 Queue Architecture, SpecificContent & Transaction Lifecycles 11.2 Queue Items SLA, Postpone, Deadlines & Priority Scheduling 11.3 Bulk Operations, Transaction Status Updates & Queue Triggers

12 Chapter 12: Orchestrator Tenant & Folder Entities

12.1 Asset Types, Per-Robot Assets & External Credential Stores 12.2 Modern Folder Hierarchy, User/Robot Assignment & Permissions 12.3 Storage Buckets, Webhooks & Environment Promotion 12.4 Orchestrator Tags: Labels, Properties & Governance

13 Chapter 13: Unattended Execution, API Triggers & Cloud Robots

13.1 Unattended Job Execution: Folders, Priorities, Background vs. Foreground & Runtimes 13.2 API Triggers: Starting Jobs from External Systems over HTTP 13.3 Serverless and Cloud VM Robots: Cloud-Hosted Execution Options

14 Chapter 14: Monitoring, Recording & Solutions Management

14.1 Orchestrator Monitoring, Trigger Alerts & Job Health 14.2 Job and Transaction Recording: Troubleshooting Faulted Unattended Jobs 14.3 Solutions Management: Packaging and Deploying Automations with Their Resources

15 Chapter 15: Debugging, Remote Debugging & Profiling

15.1 Studio Debugging Tools: Breakpoints, Panels & Execution Control 15.2 Remote Debugging: Remote Machine and Unattended Robot Connections 15.3 Profile Execution: Finding Performance Bottlenecks in Studio

16 Chapter 16: RPA Testing & Test Suite

16.1 UiPath Test Suite Overview, Test Cases & Given-When-Then Structure 16.2 Data-Driven Testing, Test Verification Activities & Mock Activities 16.3 CI/CD Pipelines with uipcli & Test Manager Traceability

17 Chapter 17: Long-Running Workflows, Action Center & Apps

17.1 Long-Running Workflows: Persistence, Suspend and Resume 17.2 Action Center & Human-in-the-Loop Orchestration 17.3 UiPath Apps: Action Apps, Automations & Integration Service

18 Chapter 18: Trigger-Based Attended Automation & Callouts

18.1 Trigger-Based Attended Automation: Forms, Triggers & Global Variables 18.2 Running Local Triggers & the Event Inspection Tool 18.3 Callouts & Forms for Attended Guidance

19 Chapter 19: UiPath Assistant & Robot Sessions

19.1 UiPath Assistant: Automations, Reminders, Widgets & Configuration 19.2 Robot Session (Picture in Picture): Child Session vs. Virtual Desktop

20 Chapter 20: Autopilot for Developers & Autopilot for Everyone

20.1 Autopilot for Developers: AI Assistance in Studio and Studio Web 20.2 Autopilot for Everyone: Chat, Automations & Clipboard AI

21 Chapter 21: API Automation & Integration Service

21.1 Integration Service: Connectors, Connections & Connector Activities 21.2 API Workflows in Studio Web 21.3 HTTP Requests: Web APIs, the Orchestrator API & Connector Requests 21.4 Connector Builder: Custom Integration Service Connectors 21.5 Integration Service Event Triggers: Connected and Disconnected 21.6 GenAI Activities: Generative AI Inside Workflows

22 Chapter 22: Data Service, Context Grounding & Coded Workflows

22.1 Data Fabric (Data Service) Entities: Modeling Business Data 22.2 Data Fabric Activities and the Platform Connector 22.3 Context Grounding: Retrieval-Augmented Generation with Company Data 22.4 Coded Automations: Structure, Arguments & Invoking Workflows 22.5 Coded Automation Services: Orchestrator, UI Automation, Microsoft 365 & Custom Services

23 Chapter 23: Integrated Scenario Practice

23.1 Integrated Scenario Practice: Designing an End-to-End Solution

6.4 Invoke Method & Invoke Code Activities

Key Takeaways Explain This Topic AI

Invoke Method calls a static method through TargetType (TargetObject left empty) or an instance method through TargetObject (TargetType left empty).

Invoke Method parameters have directions In, Out, and In/Out, and the method's return value goes to the Result property.

Invoke Code runs a VB.NET or C# method body chosen by its Language property and can use only the values passed in its Arguments collection.

Invoke Code cannot declare classes and runs as one debugging step; logic reused across projects belongs in a library or coded source file.

Last updated: September 2026

6.4 Invoke Method & Invoke Code Activities

Core Concept: When no activity does what you need, UiPath gives you two ways to run .NET code directly. Invoke Method calls one existing method on a type or an object. Invoke Code runs a small block of VB.NET or C# that you write inside the activity. The exam description lists both under Advanced Data Manipulation, so know how to configure each, how arguments flow in and out, and when a library or coded workflow is the better home for the logic.

1. The Invoke Method Activity: Static vs. Instance Invocations

When an automation requires executing a .NET method that is not exposed as a standard visual activity, developers use the Invoke Method activity. It executes any accessible method on a .NET class or object using reflection without requiring external custom code compilation.

Configuring Static Methods

To call a static method (a method belonging to the class itself, not an instantiated object):

TargetType : Set to the fully qualified type (e.g., System.IO.File , System.Math , System.Convert ).

TargetObject : Leave blank (set to Nothing ).

MethodName : Enter the exact method name as a string (e.g., "Copy" , "Round" ).

Parameters : Configure the method's input parameters in the Parameters collection modal.

Result : Map to a workflow variable if the static method returns a value.

  • Enterprise Example: System.IO.File.Copy
  • TargetType : System.IO.File
  • MethodName : "Copy"

Parameters :

  • Parameter 1: Direction In , Type String , Value in_SourcePath
  • Parameter 2: Direction In , Type String , Value in_DestinationPath
  • Parameter 3: Direction In , Type Boolean , Value True (overwrite)
  • Configuring Instance Methods

To call an instance method (a method operating on a specific instantiated object):

TargetType : Leave blank (or default null ).

TargetObject : Provide the instantiated variable name (e.g., myList , myDataTable , myStringBuilder ).

MethodName : Enter the method name (e.g., "Sort" , "Reverse" , "Clear" , "Append" ).

Parameters : Supply arguments required by the instance method signature.

Result : Map to a variable if the method yields a return value.

  • Enterprise Example: Sorting a Generic List in Place
  • TargetObject : workItemsList (where workItemsList is List(Of String) )
  • MethodName : "Sort"
  • Parameters : Empty (calls default parameterless sort)
  • Parameter Direction Types

In : Passes an argument value into the method by value.

Out : Captures a value produced by the method via a .NET out parameter.

InOut : Passes a reference into the method and captures the mutated value ( ref in C# / ByRef in VB.NET).

2. The Invoke Code Activity: Native Scripting & Architectural Tradeoffs

The Invoke Code activity allows developers to author raw Visual Basic .NET or C# code blocks directly inside a UiPath workflow. It executes synchronously within the workflow runtime process.

Configuring Arguments in Invoke Code

Unlike workflow scopes where activities share global workflow variables, Invoke Code operates in an isolated code scope. Variables must be explicitly mapped through the Arguments collection:

Direction : In (read-only input), Out (output created inside code), InOut (mutated reference).

Type : Must strictly match the .NET data type expected by the script.

Name : The identifier used inside the code snippet. ' VB.NET Code Snippet inside Invoke Code activity

' Arguments:

  • ' in_RawDataTable (In, DataTable)
  • ' in_Multiplier (In, Double)
  • ' out_SummaryDict (Out, Dictionary(Of String, Double))

out_SummaryDict = New Dictionary(Of String, Double)()

  • For Each row As DataRow In in_RawDataTable.Rows
  • Dim category As String = row("Category").ToString()
  • Dim amount As Double = Convert.ToDouble(row("Amount")) * in_Multiplier
  • If out_SummaryDict.ContainsKey(category) Then
  • out_SummaryDict(category) += amount
  • Else
  • out_SummaryDict.Add(category, amount)
  • End If
  • Next
  • Exception Handling inside Invoke Code

Unhandled exceptions inside an Invoke Code block immediately bubble up to the parent workflow as a System.Exception , halting workflow execution unless caught by an enclosing Try Catch activity.

Developers can embed internal Try...Catch blocks within the Invoke Code script to handle recoverable edge cases, log errors, or populate diagnostic Out arguments.

Architectural Decision Framework: When to Use What

Implementation Approach Execution Performance Studio Readability & Auditability Maintainability Across Projects Best Enterprise Use Case

Visual Workflow Activities Moderate (WF activity tracking overhead) High (Visual flowchart/sequence diagrams) High (Standardized out-of-the-box components) Standard UI interactions, API calls, simple conditionals, business control flow.

Invoke Method High (Direct CLR method invocation) Moderate (Hidden method parameters in dialog) High (Native .NET assembly binding) Calling single built-in .NET methods (e.g., List.Sort() , DataTable.Merge() ).

Invoke Code High (Compiled native CLR script) Low (Logic hidden inside black-box script window) Low (Script copy-pasted across workflows) Complex math, multi-dimensional array processing, fast batch operations where visual loops lag.

Custom Activity / Library (NuGet) High (Compiled pre-optimized DLL assembly) High (Visual activity with custom properties/icons) Extreme (Single source of truth via Orchestrator Feed) Enterprise-wide shared utility logic, custom system connectors, proprietary algorithms.

Important

Enterprise Governance Rule: Avoid using Invoke Code for logic that is reused across multiple automation processes. If an Invoke Code block grows long or is copied into several projects, refactor the code into a UiPath Library project , test it independently, and publish it as an enterprise NuGet package to the Orchestrator library feed.

Invoke Code Details Worth Knowing

Language. Each Invoke Code activity has a Language property (VB.NET or C#). It does not have to match the project's expression language.

Namespaces. The code can use the namespaces imported in the project's Imports panel, plus fully qualified names.

No class definitions. The body is the inside of a method, so you cannot declare classes there. Put reusable types in a code source file ( .cs ) in the project or in a referenced library.

Arguments are the only link to the workflow. Workflow variables are not visible inside the code unless you pass them in the Arguments collection, with a direction of In, Out, or In/Out.

Debugging. You cannot step through individual lines of an Invoke Code body with Studio breakpoints; the activity runs as a single step. Log values with Console.WriteLine , which writes to the Output panel, or move complex logic into a coded workflow where the IDE supports breakpoints.

Choosing the Right Tool

  • Need Best choice
  • Call one existing .NET method, such as List.Sort or System.IO.File.Copy Invoke Method
  • A short, local calculation with a loop, used in one place Invoke Code
  • The same logic used by several processes A library project or coded source file, published and versioned
  • Complex, testable logic with types, IntelliSense, and debugging A coded workflow or code source file