If - Last step

Declaration

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

Related Topics   

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, by default, any If activity added to the Task Builder's Steps panel 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.

Parameters

General

 
PropertyTypeRequiredDefaultMarkupDescription
If the last stepText (Options)YesSucceeds
  • LASTSTEP="succeeded"
  • LASTSTEP="failed"
  • LASTSTEP="failedwithcode"
Specifies the condition to be met. The available options are:
  • Succeeds - 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 codesTextYes if last step failed with specific error(Empty)RESULTCODE="24007,30098"Specifies the error codes that the previous step generated upon failure. Multiple error codes can be entered by delimiting each with a comma (for example, 24007, 30098, 20074). This parameter is available only if the If the last step parameter is set to Fails with specific error.

Description

Error Causes

On Error

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

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."

Copy
<AMIF ACTIVITY="last_step" 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 ACTIVITY="end" />