JavaScript with multiple properties for output

I created an output for my JavaScript flow control, and that output has 2 properties. When creating bindings the system sees the 2 properties fine, but the first one has a value and the second does not.

I used this code to set the values – it sees ABC but not XYZ:

return [0, { prop1: "ABC", prop2 : "XYZ"}]

Instead, if I define the first as an object and give this object 2 properties, it works with this coding:

return [0, { result: { prop1: "ABC", prop2 : "XYZ" } } ]

Why doesn’t the first way work?

Hi @Daniel_Wroblewski, did you remember to add “prop2” to the list of outputs on the right? I tried the following and it works:

Sorry, I cannot get this to work. Here’s is my JavaScript:

Then on the first output, I set a page variable that is bound to a text element. The result2 property is always undefined.

Here is the formula binding:



According to this video, it seems that if I want to return 2 properties I need to put them in an object. Though I can’t understand how you got it to work. AppGyver: How to Use Custom Javascript - YouTube

Hi, I was able to reproduce the issue now and will report it forward. Looks like it matters if you try to use both properties at once – if I try your formula, the 2nd value is undefined, but if I alert that value alone, the output seems correct. That’s why I didn’t catch it last time :slight_smile:

As you mentioned, the object method works:

1 Like

As I know, you can set 2 or more outputs but can not set 2 different property for these outputs.

So, you should set

Output 1
result → your return object, list or anything you want
Output 2
result → object {errCode: Number , errMessage: Text}

In your javascript codes catch an error (or second work conditionally)

If ( input == null ) {
 return [1, {result: {errCode: 1, errMessage: "Some error message"}}]
.... your other codes
return { result }

Using javascript

1 Like