If - Last Step

Declaration

<AMIF ACTIVITY="last_step" LASTSTEP="text (options)" RESULTCODE="number">

Description: Controls task flow depending on whether the last step was a success, general failure, or failed because of a specific error. If the result evaluates to TRUE, the task will execute the block of steps immediately following this step up until an End if step is encountered. If the result evaluates to FALSE, the block will be skipped and execution will proceed directly after the End if step (or if an Else step is encountered, the task will execute that block of steps instead, up until an End if step is encountered).

NOTE: All If activities must be followed at some point with an End if step to mark the end of the code block that is to be executed if the expression is true. For ease of use, any If activity added to the Steps pane of the task builder is always followed by an End if activity.

Practical Usage

Mainly used to provide custom error handling on steps that are set to continue on error. This activity executes conditional steps depending on the outcome of the previous step. It is commonly used to present a block of steps to be carried out if the previous step fails.

General Parameters

Property

Type

Required

Default

Markup

Description

If the last step

Text (Options)

Yes

Succeeded

  1. LASTSTEP="succeeded"

  2. LASTSTEP="failed"

  3. LASTSTEP="failedwithcode"

Specifies the condition to be met. The available options are:

  • Succeeds (default) - The IF block will be executed if the previous step succeeded.

  • Fails - The IF block will be executed if the previous step failed in general (with or without any error message generated).

  • Fails with specific error - The IF block will be executed if the last step failed with one of the error codes specified in the Comma-delimited list of error codes parameter.

Comma-delimited list of error codes

Text

Yes if last step failed with specific error

(Empty)

RESULTCODE="24007,30098"

Specifies the error code(s) that the previous step generated upon failure. Multiple error codes can be entered by delimiting each with a comma (e.g., 24007, 30098, 20074). This parameter is available only if the If the last step parameter is set to Fails with specific error.

Example

The sample AML code below can be copied and pasted directly into the Steps panel of the Task Builder.

Description: Determines if the last step returned one of these error codes: 20074, 20089. If so, a message box displays a message stating "Last step failed with one of the error codes specified." If not, a message box will display "Last step did not fail."

<AMIF LASTSTEP="failedwithcode" RESULTCODE="20074, 20089"> 
<AMSHOWDIALOG 
MESSAGE="Last step failed with one of the error codes specified." />
<AMELSE />
<AMSHOWDIALOG MESSAGE="Last step did not fail." />
</AMIF>