Loop Dataset Action

Description

Loops through the rows of the dataset specified. With each successive loop a block of steps is executed and the current row of the dataset is incremented. The loop ends when at the end of the dataset or when a Break is encountered.

Declaration

<AMLOOPDATASET DATASET="text" FROM="number" TO="number" SORT="text [options]" SORTEDCOLUMN="text [columnname]">
  (block of steps to loop)
</AMLOOP>

Examples

<!--- Demonstrates using SQL query with Loop Dataset. Gets all customer where city field is San Diego. Then writes names to a file, to make this Workflow work change the SQL Query connection string and query to match your database--->
<AMSQLQUERY CONNECTIONSTRING="19y9I4LjuL6U1z5kWV9qNz7f2GrLdS16HzZ2IABihh5oydIvZvKxirNVsXfr02s5+YSmraH478OnG3fyNDrnr4k2lmJKCFqoQ/poQgCblLO4gyfnpETTF3SS5ARqugxsajhx7hYL0OypO7YoBsI0EMMvOE56AM64O" RESULTDATASET="myresults">SELECT firstname, lastname from customer where city='San Diego';</AMSQLQUERY>
<AMMESSAGEBOX>%myresults.TotalRows% customers found</AMMESSAGEBOX>
<AMLOOPDATASET DATASET="myresults">
<AMFILEWRITE FILE="c:\customerlist.txt">%myresults.firstname% %myresults.lastname%</AMFILEWRITE>
</AMLOOP>

 

<!--- This example checks the pop3 mailbox and if a message contains the subject 'Get out of Debt' then it is deleted. To make this Workflow work - modify both POP3 steps with the proper server and account information --->
<AMPOP3MAIL RESULTDATASET="themessages" SERVER="mail.server.com" USERNAME="username" PASSWORD="1Zb00y6hQv2ZqWN7qDphOEw==">
<AMLOOPDATASET DATASET="themessages">
<AMIFCONTAINS TEXT="%themessages.Subject%" SUBSTRING="get out of debt">
  <AMMESSAGEBOX>Deleting message with %themessages.subject%</AMMESSAGEBOX>
  <AMPOP3MAIL ACTION="remove_message" MESSAGE="%themessages.currentrow%" RESULTDATASET="themessages" SERVER="mail.server.com" USERNAME="username" PASSWORD="1Zb00y6hQv2ZqWN7qDphOEw==">
</AMIF>
</AMLOOP>

General Tab Parameters

Dataset name: Specifies the name of a previously created dataset. Example actions that create datasets are SQL Query, POP3 Mail, and Stored Procedure.

Text, Required
MARKUP: DATASET="DATASETNAME"

Optional parameters:

Start row: Specifies the record (row) to start on when moving through the dataset.

Number, Optional Default - 0
MARKUP: FROM="20"

End row: Specifies the record (row) to stop on when moving through the dataset. If omitted or set to 0 the End Row is the last in the dataset.

Number, Optional - Default 0
MARKUP: STEP="2"

Advanced Tab Parameters

Output list: Specifies whether a sort order should be applied to the values before the loop begins. If using Loop Dataset with a SQL Query, in most cases it will be more efficient to perform the sorting as part of the query instead of using this option. If ascending or descending specified, a valid column name to sort on must also be specified.

  • Do not sort the list (none): The results are left in their natural order and not sorted.

  • Sort the list in ascending alphabetical order (ascending): The results sorted in ascending alphabetical order.

  • Sort the list in descending alphabetical order (descending): The results sorted in descending alphabetical order.

Text [options], Optional (default "none")
MARKUP: SORT="ascending"

Sort on column: Specifies the column to sort on if Output List [SORT=] is set to ascending or descending.  Must specify a valid field/column name.

Text, Required if SORT is ascending or descending
MARKUP: SORTEDCOLUMN="LastName"

See Also

Loop, End Loop, Loop Files, Loop Windows, Loop Processes, Loop Expression, Loop List, Break