About EasyMorph Tutorials & Examples Web-help

Dynamical genereting of path based on previous step

Hi everyone!
Maybe I didn’t formulate my request correctly, but I could not find that:

The case: i need to read email with xls attachment(s), download it,convert to xml, and send forvard.
So I chose @save files into temt folder.
How may i get name of folder from previous step into next step dynamically?
Flow looks like(in my head):
1- Fetch emails,save attachments to temp folder
2- Import xls from previos step folder(maybe more than 1)
3- convert into xml
4- send result forward to web service

Thank you, have a nice day!

Hi @riko_chaos and welcome to the Community!

How many requests to a web service do you need to send? One request per XLS file, one request per email message, or one request per execution of the “Fetch email” action?

Hi @andrew.rybka! thank you for response.
I need a request per email.
there is a cases when its can be more than one xls per email, but one email - it’s one client, so it need to be one entity(one request).

Here is an example project with the following workflow:

  • Fetch attachments to temporary folders
  • Calculate folder name and file extension of each of the fetched attachments
  • Use deduplicate to create a list of unique folder names
  • Iterate over the folders list and call the “Import and send” module once for each folder\message

The “Import and send” module accepts attachments folder path and some client identifier (this example uses email address). The workflow of the module is as follows:

  1. List attachment files in the specified folder and filter out non-XLSX files
  2. Import all the listed XLSX files. Only the first sheet will be imported from each file. You should change that behavior according to your requirements
  3. Create XML from the imported data and add client’s identifier to it
  4. Send XML to a web service

You should change Web location connector properties and steps 3 and 4 according to your API requirements.

Here are some screenshot and the example project itself:

FetchEmailsAndSendWebRequestUpdated.morph (14.8 KB)

@andrew.rybka hi there! You are great! Thanks a lot!
Thats a flow which I needed!

But one more question, with that i stopped: module “Import and send” can’t get data about folder:

Error: Parameter {AttachmentsFolder} has invalid value for Folder.
Source: action “List of files”, module “Import and send”, table “List attachments in the specified folder”

I assumed that the problem with my file system is the names in Russian, and changed the temporary folder to “D:\mail_tmp{**uid temp folder}”. But this did not solve the problem, an error still occurs.
The project took your whole, changed only the directory.
Maybe I missed something in the documentation? Or something else?

Thanks you a lot!

@riko_chaos, you are welcome!

That error appears when the {AttachmentsFolder} parameter is either empty or contains only whitespace characters.

If the “Main” module gives you that error, it means that the “Fetch email” action fetched a message which has no attachments at all. I updated my example and added a filter action that will just remove all the messages without attachments from the fetched dataset. Please download it from my previous post.

But for the production use, it’s better to add some kind of validation to detect cases when an email message should have an attached XLSX file but it hasn’t.

Also, this error may appear if you are trying to run the “Import and send” module on its own. In such a case you should specify temporary parameters in the left sidebar. They are specified on the second screenshot, but I had removed them from the project before publishing it.

The “Iterate” action assigns those parameters on each iteration from column values, so they should be filled only for debugging purposes.

@andrew.rybka hi again!
At first - thank you for help!
But i need more help :frowning:

Parameter AttachmentFoldet - does`nt sork. You can see it on screenshots.Can it be my local problem?Can you try it on your side?

What can i do with this? I can’t see in this program any debugger or view of “clear transfering data” … as i see - Folder data - is text with normal state…it’s blowed up my brain (

@riko_chaos, are you trying to run the “Import and send” module on its own?

Parameters will be automatically passed to that module only when you are running it from the “Main” module.

When you just open the “Import and send” module and try to run the whole module or some of its actions, it will use parameter values, declared in the module itself. And since parameter values in my example are empty, that error is displayed.

@andrew.rybka hi!
Identified a problem. There was an error on my part - in the letters that were in the box there was no .xlsX - by which filtering was configured. This is exactly what causes the problem. But the embarrassment is that the filter is after the formation of the list of files, and the error is displayed precisely on the formation of the list of files. In the settings it is indicated - to stop the execution process, in case of an error … that is why I thought that the process does not reach the filter step, and the error lies in the file list creation node.
Now I will test again.

To learn more about EasyMorph visit easymorph.com.