HI
I have a small C# code that returns the name of the file. like this
[Workflow]
public stringExecute()
{
//do some logic
string fileName=“Some file name”;
return fileName;
}
I am calling this C# code from my main.xaml through Invoke Workflow File activity and supplying the name of .cs file.
how do I capture the return value so that I can use that value subsequently
Hi @ganesh.panchagnula
Welcome to UiPath.
In Main.xaml , add Invoke Workflow File activity, set WorkflowFileName to Code.xaml. In Arguments, create out_FileName, Direction: Out, Type: String.
Create a variable fileName (String), then assign fileName = out_FileName.
Add Log Message activity and set fileName as the message to verify the output in logs.
If you found helpful mark as solution tick.
Hi @ganesh.panchagnula,
Use invoke code activity, set language as c#.
// Declare the file name variable
fileName = "Some file name"; // Assign a value to the UiPath argument
Invoke Code.zip (11.5 KB)
Regards,
Arivu
Hi,
If you just want to use the method, it may be better to use not Coded Workflow but Code SourceFile. The following sample may help you.
Sample
Sample20250327-1.zip (18.8 KB)
Regards,
Hello,
LoginError made a repo giving a ton of examples of using coded workflows which is useful to reference.
This one shows an example of a coded workflow that can return values which you should be able to use to see how to use both input arguments and output arguments.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.

