ungrouped job: get original job folders file count
Posted: Sun Nov 25, 2012 12:37 pm
Hi,
I have only recently started to poke around Switch scripting and am unsure how I should start solving the following situation:
- as input my flow can get single files, but usually folders with subfolders so I have an Ungroup job in the beginning
- after ungrouping I send the individual files to another application via Generic Application element
- after that I would need the flow to wait until the generic application's out folder has received all the files that originally were in the now ungrouped job before moving on
How should I approach this problem? I have tried
- adding script element before the ungroup job to have a variable with job.getFileCount(), but I could not call the variable in another script element later on.
- job.getPrivateData("Ungroup.NumFiles") in the element where I need to compare the values but it seems that Ungroup does not automatically write that NumFiles value to its private data? Therefore, I also tried to setPrivateData("Ungroup.NumFiles",fileCount) with the variable I got from job.getFileCount(), but neither that could i call later on with job.getPrivateData("Ungroup.NumFiles")...
So how do these things work? Do I need to (and how to do it..) define a global variable that could be called from different elements in a flow? Or how should I work with the job's private data? I appreciate any assistance in getting me to the right direction.
best regards,
--patrik
-Edit-
one more thing: I'm also confused about when to use a script element and when to use a script expression e.g. in a connection. I can do more with a script element but are there cases where using script expression is the recommended way?
I have only recently started to poke around Switch scripting and am unsure how I should start solving the following situation:
- as input my flow can get single files, but usually folders with subfolders so I have an Ungroup job in the beginning
- after ungrouping I send the individual files to another application via Generic Application element
- after that I would need the flow to wait until the generic application's out folder has received all the files that originally were in the now ungrouped job before moving on
How should I approach this problem? I have tried
- adding script element before the ungroup job to have a variable with job.getFileCount(), but I could not call the variable in another script element later on.
- job.getPrivateData("Ungroup.NumFiles") in the element where I need to compare the values but it seems that Ungroup does not automatically write that NumFiles value to its private data? Therefore, I also tried to setPrivateData("Ungroup.NumFiles",fileCount) with the variable I got from job.getFileCount(), but neither that could i call later on with job.getPrivateData("Ungroup.NumFiles")...
So how do these things work? Do I need to (and how to do it..) define a global variable that could be called from different elements in a flow? Or how should I work with the job's private data? I appreciate any assistance in getting me to the right direction.
best regards,
--patrik
-Edit-
one more thing: I'm also confused about when to use a script element and when to use a script expression e.g. in a connection. I can do more with a script element but are there cases where using script expression is the recommended way?