Task - Stop

Declaration

<AMTASK MANAGEDTASK="text" PASSWORD="text (encrypted)" />

Description: Stops execution of the current task. Supports status code output, including Success, Aborted or Error. If the status code is set to Error, this activity supports output of a custom error number and/or text to the Event Log.

Practical Usage

Commonly used inside an If activity to immediately stop execution of the current task if a certain condition is met. Conveniently returns a status or error number/text to output to other applications.

General Parameters

Property

Type

Required

Default

Markup

Description

Status type

Text (options)

Yes

Aborted

STATUSTYPE="SUCCESS"

The type of status to return when the task stops. The selected status will appear in the Event Log. The available options are:

  • Aborted (default) - The task will return an aborted status.

  • Success - The task will return a success status.

  • Error - The task will return a user defined error number and/or text.

Start a managed task

Number

Yes

(Empty)

ERRORNUMBER="123"

The user-defined error number that should be returned when the task stops. This parameter is available only if the Status type parameter is set to Error.

Password (Optional)

Text

No

(Empty)

ERRORTEXT="ErrorBad"

The user-defined error text that should be returned when the task stops. This parameter is available only if the Status type parameter is set to Error.

Examples

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

Sample1: Stop this task and throw an error using custom error number "8080" and custom error text "ErrorBad".

<AMSTOPTASK STATUSTYPE="ERROR" ERRORNUMBER="8080" ERRORTEXT="ErrorBad" />

Sample 2: Stop this task if the condition in step 1 returns FALSE.

<AMIF EXPRESSION="1 = 2">
<AMSHOWDIALOG MESSAGE="If the previous step returns TRUE, 
this message box will be displayed." 
WINDOWTITLE="TRUE" />
<AMELSE />
<AMSHOWDIALOG MESSAGE="If the previous step returns FALSE, 
this message box will be displayed and the following step 
will stop this task." WINDOWTITLE="FALSE" />
</AMIF>
<AMAUTOMATE BACKUPARCHIVENAME="C:\temp\backup.ama" />
<AMAUTOMATE ACTIVITY="write_to_log" TEXT="Test" />