Issue with Coded Workflow

using System;
using UiPath.CodedWorkflows;

namespace TestVacationStage2
{
public class Sum : CodedWorkflow
{
[Workflow]
public int Execute(int Number1, int Number2)
{
// Perform the sum operation
Result = Number1 + Number2;

        // Print inside UiPath Output Panel (for debugging)
        Console.WriteLine($"The sum of {Number1} and {Number2} is: {Result}");
        return Result;  // This returns the sum value to the caller
    }
}

}

I have created .cs file in UiPath and invoked in invoke workflow and passed Number1 and Number2 as input and Result as Output. But i am not able to get output back out of invoked workflow.

@oraganti931

if you want get out of the data from workflow, you must create out argument for output inside of your flow outside of the flow you can assign any variable and you can map it

Use debug first check inside work flow, are you getting output from invoke code or not

we recommend following the recommendation that Variable Names will follow the CamelCase style.

We observed similar behaviour and changing it to CamelCase form did help.

Give a try at:
Result → renaming to: myResult
and similar to other arguments and variables

Let us also know which Studio Version is used

Do you know what is this based on?

I’m not saying you’re wrong by any means, just want to understand how could something like this be an issue.

Hi @oraganti931,

Copying the above code and validating the project will yield:

Compilation will fail anyhow:

There is a problem with the attached code so the code is not compilable - you must declare the Result variable as var Result.

Once you do that it will work:

Also attached the project here:
InvokeSample.zip (16.0 KB)

You can find more samples with workflows - coded workflows interopability over in our Samples Repository.

1 Like