{{ transformations:IterateAction.png}} ====== ITERATE ====== Category: Workflow / Internal \\ \\ =====Description===== This action calls another project once for each row in a table. Parameters of the called project are assigned using the calling table's fields.\\ \\ =====Use cases===== //Iterate// is used to create "FOR…EACH" and "FOR…NEXT" types of loops within EasyMorph. \\ =====Action settings===== ^Setting^Description^ |Module/Project to run*|Select whether to call a module (within the current project), or an external project (.morph file), then select the\\ module, or browse to the project file.| |Iteration mode|Choose whether to just iterate the called module (or project) and //not// return any results, or iterate and return\\ a dataset. Options: //Iterate// or //Iterate and append results// (and select the Result table from the called module or project).| |Assign parameters|Select the parameters in the called module (or project) to pass values in with, and the associated columns* in the\\ calling dataset that contains the values being passed.| |When an iteration fails|Select how EasyMorph will handle situations when iterations fail. Options: //Halt project// or //Collect errors and continue//\\ (a new column, "Iteration errors", will be created in the dataset to capture any errors that occurred\\ during the iterations).| * Setting can be specified using a [[:parameters|parameter]].\\ \\ =====Remarks===== Appending the result datasets is similar to the [[transformations:append|Append another table]] action. Columns with the same name are concatenated into one column while columns with unique names are extended with empty cells.\\ To create a "FOR...NEXT" type of loop, generate a sequence of numbers from 1 to N using the [[transformations:sequence|Sequence]] action, then iterate across the sequence using //Iterate//.\\ \\ =====Examples===== **Iterate** — do not return anything from the iterated module, i.e. just run it one or several times. {{ https://easymorph.com/images/learn/iterate-mode1.png }} \\ \\ **Iterate and append results** — run the module one or several times, return a table (the result dataset) from each iteration, and append all result datasets into one, which becomes the output of the "Iterate" action. {{ https://easymorph.com/images/learn/iterate-mode2.png }} \\ =====Community examples===== * [[https://community.easymorph.com/t//466/1|Sending an email notification when project fails]] ([[https://community.easymorph.com/uploads/short-url/8MVDPxoPY14RwNbwTFKOzYgrbCD.morph|Project]]; Module: //Main//; Group: //The "Skip" action//; Table: //Example 2//; Action position: //3//) * [[https://community.easymorph.com/t//1766/1|Load only workbooks with given number of sheets]] ([[https://community.easymorph.com/uploads/short-url/AbWPlfPVBecqgZUBVTYlljwb9NO.morph|Project]]; Module: //Main//; Group: //Tab 1//; Table: //Get file names to load//;\\ Action position: //3//) * [[https://community.easymorph.com/t//2004/4|Get Date from Year, Week and Day of Week]] ([[https://community.easymorph.com/uploads/short-url/7ERZplXAq4auZQqPk8cli327Dgv.morph|Project]]; Module: //Module 1//; Group: //Tab 1//; Table: //Table 1//; Action position: //2//) * [[https://community.easymorph.com/t//2156/1|How to process parent-child data structures]] ([[https://community.easymorph.com/uploads/short-url/zmylfn4Qr0ovzu3e5rybl0LVMNG.morph|Project]]; Module: //Get subfolders//; Group: //Tab 1//; Table: //Table 1//; Action position: //2//) \\ =====See also===== * [[transformations:iteratecolumn|Iterate column]] * [[transformations:iteratetable|Iterate table]] * Read [[http://easymorph.com/learn/iterations.html|Iterations and loops in EasyMorph]] for more details regarding this action.