# How to Use Invoke Code

**URL:** <https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947>\
**Category:** Activities\
**Tags:** question, system, activities\
**Created:** [April 9, 2026, 9:01am UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947 "2026-04-09T09:01:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![692622](https://avatars.discourse-cdn.com/v4/letter/6/f9ae1b/32.png) [@692622](https://forum.uipath.com/u/692622)\
**Post date:** [April 9, 2026, 9:01am UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/1 "2026-04-09T09:01:18Z")

</div>

Dim A As String = “SNP”  
Dim B As String = “500”  
Dim C As String = A & “\_” & B

I wrote code like the above in the code section of the Invoke Code activity, and I want to use the resulting value of C in subsequent steps.

1. How can I retrieve the result of the code written in Invoke Code and use it outside the activity?
2. I want to pass a specific value created outside Invoke Code into the activity and use it in the code. For example, how can I declare a value such as `Name = "Samsung"` using Assign, pass that value into Invoke Code, and apply methods such as `.Split` to it inside the code?

=================================================

English version

I am writing code like the above inside the **Invoke Code** activity, and I want to use the resulting value (C) outside of that activity.

1. How can I retrieve the result value from the code inside the Invoke Code activity and use it outside the activity?
2. I also want to pass a value created outside of the Invoke Code activity into it.  
For example, if I declare a value using Assign like `Name = "Samsung"`, how can I pass this value into the Invoke Code activity and apply methods like `.Split` inside the code?

---

<div class="post-metadata">

**Author:** ![chinthakayala\_karthik](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/chinthakayala_karthik/32/543966_2.png) [@chinthakayala\_karthik](https://forum.uipath.com/u/chinthakayala_karthik)\
**Post date:** [April 9, 2026, 9:10am UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/2 "2026-04-09T09:10:38Z")

</div>

Hello @692622,

You need to use the **Arguments** section of Invoke Code.  
To send a value into Invoke Code, create an **In** argument.  
To get a result back outside, create an **Out** argument.

Example in VB:

**Arguments**

- `in_A` → In → String
- `in_B` → In → String
- `out_C` → Out → String

**Code**

```auto
out_C = in_A & "_" & in_B

```

Then map `in_A = A` , `in_B = B` , and `out_C = C` .

For an outside variable like `Name = "Samsung"` , pass it as an **In** argument:

```auto
Dim arr() As String = in_Name.Split(" "c)
out_FirstPart = arr(0)

```

That is the standard way to consume external values inside Invoke Code and return results back to the workflow.

Thanks,  
Karthik

---

<div class="post-metadata">

**Author:** ![Rohit\_More](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rohit_more/32/235584_2.png) [@Rohit\_More](https://forum.uipath.com/u/Rohit_More)\
**Post date:** [April 9, 2026, 10:17am UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/3 "2026-04-09T10:17:10Z")

</div>

@692622

In Invoke Code activity, click **Edit Argument** as shown in below screenshot and create required in and out argument, click ok then **Save**.

 ![image](https://global.discourse-cdn.com/uipath/original/4X/2/3/5/23515e382206a5b8bfcb72cf5957949896956491.png)

then click **Edit Code** , here you can write your code and use the arguments created:

 ![image](https://global.discourse-cdn.com/uipath/original/4X/a/c/7/ac73baad7199d36f4041da1c345e484c0f03ad8c.png)

---

<div class="post-metadata">

**Author:** ![himanshu.chopra](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/himanshu.chopra/32/497687_2.png) [@himanshu.chopra](https://forum.uipath.com/u/himanshu.chopra)\
**Post date:** [April 9, 2026, 7:56pm UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/4 "2026-04-09T19:56:15Z")

</div>

To pass values in and out of the **Invoke Code** activity, you must use the **Arguments** panel. Think of arguments as the “bridge” between your workflow variables and the code inside the activity.

Here is exactly how to set it up:

### 1. Define the Arguments (The Bridge)

In the **Properties** panel of your Invoke Code activity, click the three dots `...` next to **Arguments**. Set them up like this:

| **Name (Inside Code)** | **Direction** | **Type** | **Value (Outside Variable)** |
| --- | --- | --- | --- |
| `Name` | **In** | String | `str_Name` (Created via Assign) |
| `ResultC` | **Out** | String | `str_Result` (Variable to hold the output) |

- **In:** Brings data from your workflow into the code.
- **Out:** Sends data from your code back out to your workflow.

* * *

### 2. Write the Code

Inside the **Edit Code** window, you do **not** need to use `Dim` for any variable defined in the Arguments list. You can use them directly.

=========================================================  
Code snippet:

’ 1. Using the “In” argument (Name) passed from outside  
’ Example: Applying .Split to “Samsung”  
Dim parts As String() = Name.Split("s"c)

’ 2. Your logic for SNP\_500  
Dim A As String = “SNP”  
Dim B As String = “500”

## ’ 3. Assign the result to the “Out” argument, This value will now be available in your str\_Result variable outside ResultC = A & “\_” & B

=========================================================

### 3. Key Rules for Success

- **No Redeclaring:** Do not use `Dim ResultC As String` inside the code if you already defined `ResultC` in the Arguments list. If you do, the code will create a local variable and won’t send the value back out.
- **Argument Direction:** If you want to modify a variable and send it back out (like changing “Samsung” to “SAMSUNG”), use the **InOut** direction.
- **Case Sensitivity:** Ensure the names in your code match the names in the Arguments list exactly.

---

<div class="post-metadata">

**Author:** ![Jon\_Smith](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jon_smith/32/523286_2.png) [@Jon\_Smith](https://forum.uipath.com/u/Jon_Smith)\
**Post date:** [April 9, 2026, 11:07pm UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/5 "2026-04-09T23:07:33Z")

</div>

Guys, Invoke code is effectively legacy.

We have had coded workflows for years.  
Just write this in a coded workflow for a proper coding experience and better handling, there is no need to suffer through invoke code now.

---

<div class="post-metadata">

**Author:** ![692622](https://avatars.discourse-cdn.com/v4/letter/6/f9ae1b/32.png) [@692622](https://forum.uipath.com/u/692622)\
**Post date:** [April 10, 2026, 1:03am UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/6 "2026-04-10T01:03:28Z")

</div>

I followed the method you suggested, but the result is coming out as **null**.  
Is there something I might have missed?  
Or could there be another issue causing this?

// here is my logic

 ![제목 없음](https://global.discourse-cdn.com/uipath/original/4X/6/9/8/69830f59479dde33fdab5b08793ebe4f30e6b8db.png)

---

<div class="post-metadata">

**Author:** ![692622](https://avatars.discourse-cdn.com/v4/letter/6/f9ae1b/32.png) [@692622](https://forum.uipath.com/u/692622)\
**Post date:** [April 10, 2026, 1:06am UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/7 "2026-04-10T01:06:49Z")

</div>

I’ve posted the method I tried in the comments.  
It seems like it didn’t work properly in the end—could you please take a look?

---

<div class="post-metadata">

**Author:** ![David\_Hernandez2](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/david_hernandez2/32/553801_2.png) [@David\_Hernandez2](https://forum.uipath.com/u/David_Hernandez2)\
**Post date:** [April 21, 2026, 2:53pm UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/8 "2026-04-21T14:53:55Z")

</div>

As long as you don’t mind all the bugs that come with coded workflows.. sure.

---

<div class="post-metadata">

**Author:** ![Jon\_Smith](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jon_smith/32/523286_2.png) [@Jon\_Smith](https://forum.uipath.com/u/Jon_Smith)\
**Post date:** [April 21, 2026, 10:58pm UTC](https://forum.uipath.com/t/invoke-code-how-to-use-invoke-code/5736947/9 "2026-04-21T22:58:16Z")

</div>

That feels abit passive aggressive.  
I don’t experience the bugs you talk of, tell me what bugs occur in situations like this that makes invoke code superior?
