cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to pass a variable along the pipeline?

graham-onpoint
New Contributor II

I have a pipeline that looks like this:

image

The Snaps are:

  1. List all files in a given Box directory
  2. Filter the files according to a mask
  3. Read the matching Excel file into the pipeline
  4. Convert the first Worksheet to CSV
  5. Write a CSV file to an archive folder in Box
  6. Delete the original Excel file

Everything is working up to step 5, where I need to access the output variables of step 2 again, the FileName is needed to create the matching file name in the archive folder (except this time with a .csv extension) and then the FileId is needed in step 6 in order to delete the Excel file.

The business reason behind doing this is that the file coming in to the Box folder will have a date prefix at the front of it. There is no set frequency for this file, it is practically arriving at random intervals. Therefore, I have no way to hard code the actual file name into the Pipeline and must dynamically check for a new file every day.

How can I store the output fields from step 2 somewhere in memory so that the final two Snaps in the pipeline can access them?

image

8 REPLIES 8

tstack
Former Employee

Note that you are combining ALL of the Excel files found in the directory into a single CSV file. Is that really your intention here?

Youโ€™ll need to move part of the pipeline into a child pipeline and pass the file name as a parameter to the child. Iโ€™m going to guess you probably donโ€™t want to combine all of the Excel files into one file, but rather have one CSV file per input file. Using a child pipeline will fix that issue as well.

So, I would move the โ€œRead XLSXโ€ and following snaps into the child pipeline and add a filename parameter. Then you can place a PipelineExecute snap after the Filter to kick off the child and pass down the file name from document output by the Box Directory Browser.

Thanks for the quick reply.

No, the mask applied picks up only one file. I understand that I might need to handle multiple files in future, but thatโ€™s unrelated to my question here.

Just to clarify what youโ€™re saying here, the only way to accomplish this is with a Child Pipeline and a PipelineExecute Snap. There is no way to pass the variable โ€œupโ€ into the Pipelineโ€™s โ€œsessionโ€.

Is that correct?

Correct, there is no way to pass a variable โ€œupโ€. To elaborate on that a bit, the snaps all run in parallel, so there would be a race between the snap that is passing the variable โ€œupโ€ and the snap that is trying to read the variable. For example, if there were two files coming in, the Write snap might see the first file name in one execution and the second file name in another execution.

I can see how that would happen, but could that not be controlled with a ForEach Snap that serializes the processing?

The use case you are thinking of would require a child pipeline due to the race condition, however it is not a requirement for the pipeline I am developing as (a) there will only be one file, and (b) it is acceptable to stop processing and throw an error if there is more than one file.