Dim A As String = “SNP”
Dim B As String = “500”
Dim C As String = A & “_” & B
Invoke Code의 코드 부분에 위와 같은 코드를 작성하고
결과적으로 C값을 받아와서 이후 작업을 하려고 합니다.
Invoke Code에 작성된 코드의 결과값을 해당 엑티비티 밖에서 받아서 사용 하려면 어떻게 해야 하나요?
Invoke Code 밖에서 만들어진 특정 값을 Invoke Code의 내부에 넣어서 코드를 적용 시키고 싶습니다. 가령 Assign 등으로 Name = “Samsung” 이라는 값을 선언 하고 이 Assign으로 선언된 값을 Invoke Code의 내부에 넣어 .split 등 의 메소드를 적용 시키려면 어떻게 해야 하나요??
=================================================
English ver
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.
How can I retrieve the result value from the code inside the Invoke Code activity and use it outside the activity?
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?
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
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:
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.
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.
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.
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.
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?
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?