Multiple variables in workflow result variable

Hi Team,

We have a requirement to pass the two variables in resultvarible of workflow step . is three any way to achieve this
Need to pass “Exist” and “Normal account” in resultVariable
EX:

Thanks,

The easiest way I can think of to solve this problem is merging both variables into a single string (with String .join() method for example), return that string as the resultvariable and, in the following step, use the String .split() function to extract both variables from the string.

Thanks for your replay

variable type is Boolean and another one string

There is no problem, here is an example code:

In step 1:

//Declare variables
boolean myBoolean = true;
String myString = "HelloWorld";

//Merge variables into a single string
String mergedString = myBoolean + ";" + myString;
System.out.println("Merged String: " + mergedString);

In step 2:

// Split the merged string
String[] parts = mergedString.split(";");
        
//Convert back to original types
boolean extractedBoolean = Boolean.parseBoolean(parts[0]);
String extractedString = parts[1];

Does it matter if it actually goes into resultVariable as long as you can use it later in the workflow? If not, you can always just call something like this in the workflow step:

wfContext.setVariable("myFirstVar", "Exist")
wfContext.setVariable("mySecondVar", "Normal account")

or

workflow.put("myFirstVar", "Exist")
workflow.put("mySecondVar", "Normal account")

@sureshbomm You can keep those 2 variable in Map and pass it as resultVariable

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.