How to get a proper value from multi-output node?

Hello! I’ve set up a sample workflow where my main function returns four items. I know how to access its value by using SplitInBatches, but I want to know how to make it in a ‘parallel’ way. My sample data has some ids from 1 to 4 and I want to get their corresponding values after the IF node without the relative reference (via $json), but via $node reference. But both my Set nodes return the same data.

Workflow code:

Hey @barn4k,

Welcome to the community :sparkling_heart:

Thank you for providing the example workflow. I ran the workflow and noticed that you’re using the same reference in both the Set nodes. The expression with $node returns the data from the node, irrespective of the condition. Can you please explain why you don’t want to reference the data using $json? It would be helpful if you can explain the use case :slight_smile:

In a more complex scenario, I have some alerts from MS Security API that have an alert_id and a computer_name reference. Then I look for the owner of this computer in the LDAP. After that, I need to send an email with both the alert_id and computer_name to the end-user. So I can’t reference the $json property in the send_email node as I have two different data sources for it (LDAP for the user_email and MS Security for the alert_id and computer_name)

I’ve prepared a more visible example. I want to send an email only if the user is an admin. And the email must have an alert and computer information.

In this example I have 4 alerts (but their ID can be unique strings or uuid):

  • alert id 1 - pc100
  • alert id 2 - pc200
  • alert id 3 - pc300
  • alert id 4 - pc400

In “LDAP” function I have pairs of PC and users:

  • pc100 - Sam
  • pc200 - Tom
  • pc300 - Dave (Admin)
  • pc400 - Bob (Admin)

And my Send Email node has completely messed data. So the only option here is to write some function to compare the data and build the right JSON?

Thank you for sharing this. I am assuming that the get PC info from LDAP node would be an HTTP node to make the API request? If yes, would you be passing the computerName with the API call, or do you make a single API call that returns the information of all the users?

The get PC info from LDAP node is a Lambda function with a python ldap3 module that receives a JSON input for each of the alert entries. So if I have 10 alerts, then it will be 10 LDAP calls

Hey @barn4k,
In that case, the Set node should return the data relevant to that iteration.

I tried out your workflow, and the get PC info from LDAP node and get Alert from MS node do not contain any common data (eg. ID, email, etc.). If both the nodes returned an identical field, you could use the Merge node to merge the node, and then pass it to the next nodes in your workflow.

Ah, I got it. So the best option here is to merge data before IF/Switch nodes and then use a relative path ($json)? As the iteration process starts to get executed differently after those nodes