Here at the company we're still new to Switch, we've only had it for a few months. So there's a lot still to learn and figure out as we get more experience.
At the moment we are trying to automate a particular task and are having a hard time figuring out how to solve it.
We have the licenses for the Switch Core Engine, and the Configurator, Metadata and Scripting modules.
I'll try to describe the process the best I can and also what we've tried so far.
If there's any other information about the process, the flows, or the configurators that I can provide that would be useful, just let me know.
Every day we do the following procedure:
- We receive an email with the name of the .pdf files that will be arriving that day, among other characteristics.
The email isn’t necessarily the first thing to arrive. Sometimes it is, other times we have already received some .pdf files when the email arrives. - We receive an N number of .pdf files
They don’t arrive together, they arrive individually throughout the afternoon, to a shared folder. We don’t know the time they start or end arriving. - We grab all the .pdf files received that day and merge into a single .pdf.
The order of the merge isn’t relevant, all we need is to make it a single .pdf. - We process the final .pdf.
What we want to achieve is a an automated process, which receives the email data and the .pdf files, and merges the .pdf files into a one, by either comparing the number of files expected for the day, or comparing the names of the files to the ones on the email, which we can then process as we like.
With Switch we have managed to automate some steps of the process:
- Receive the email as .txt and use a script to process its information to determine the total number of expected .pdf files. It should be easy to get the names of the files instead, if we’d have to. (view attachment: mail-receive-process.png)
- Merge the .pdf files into a single one with the Merge configurator, by (manually) passing a Folder with the .pdf files inside.
or - Having a fixed number of files, use the Assemble Job configurator to assemble the .pdf files into a Job Folder, and then using the Merge configurator to join them into one. (view attachment: assemble-merge.png)
We have tried the following:
- On the Script, after processing the file, assigning the total number of expected files to a GlobalData variable.
Result: We can’t access the variable from the Assemble Job configurator - On the Script, after processing the file, assigning the total number of expected files to a PrivateData key, and send this .txt file as a job to the Assemble Job configurator, solely so it can read its PrivateData.
Result: The configurator receives the variable as the job arrives, but as soon another job (one of the .pdf files for merging) arrives, the variable no longer exists in this new job, and the .pdf is sent to the Problem Jobs folder. - Use a Switch.Counter, which is updated in the Script, to save the total number of expected files.
Result: The configurator waits for the number of files to be reached, but for some reason, the Counter seems to keep increasing and the flow won’t proceed. Also, we can’t reset the Counter. - Make a loop which receives the .pdf files and does Assemble Job and Disassemble Job until the total number of files in the Assembled job is equal to the number in the Counter.
(view attachment: assemble-loop.png)
Result: The Counter seems unreliable, as it seems to keep incrementing with no reason. We tried using brand new counters and running the script only once, and even activate the flow once without deactivating, and placing the exact number of files as the counter all at once, and it still failed. Despite that, this option doesn’t seem to be practical or efficient, being as it processes files several times without real need for it.
- Using the Hold Job configurator, with a release condition
We suppose this won’t solve our issue, if we keep using the Counter as a comparison element.
Thank you,
Owen