ACCEPT command

Creates a dialog box that interactively prompts users for one or more script input values. Each input value is stored in a named character variable.

Note

Using the ACCEPT command to enter passwords is not secure. You should use the PASSWORD command instead.

The ACCEPT command is not supported in AX Server analytics.

You can create a more advanced interactive dialog box with the DIALOG command.

Syntax

ACCEPT {message_text <FIELDS project_item_category> TO variable_name} <...n>

Parameters

Name Description
message_text

The label displayed in the dialog box used to prompt for input. Must be a quoted string or a character variable.

When entering multiple prompts, you can separate them with commas. Using commas improves script readability, but it is not required:

ACCEPT "Specify a start date:" TO v_start_date, "Specify an end date:" TO v_end_date
FIELDS project_item_category

optional

Creates a drop-down list of project items for user input instead of a text box. The user can select a single project item, field, or variable from the list.

project_item_category specifies which item types to display in the list. For example, specifying xf displays all the project tables in the list. Enclose project_item_category in quotation marks:

FIELDS "xf"

For the codes used to specify categories, see Codes for project item categories.

You can specify more than one code in the same prompt, but you cannot mix project items, fields, or variables.

TO variable_name

The name of the character variable to use to store the user input. If the variable does not exist, it is created.

If the variable already exists, its current value is displayed in the dialog box as the default value.

Note

You cannot use non-English characters, such as é, in the names of variables that will be used in variable substitution. Variable names that contain non-English characters will cause the script to fail.

The ACCEPT command creates character variables only. If you need input of another data type, you must convert the character variable to the required type in subsequent processing in a script. For more information, see Input data type.

Examples

Prompting the user to select the Analytics table to open

You require a dialog box that prompts the user to select the name of the table to open. The script then opens the table the user selects:

ACCEPT "Select the table to open:" FIELDS "xf" TO v_table_name 
OPEN %v_table_name%

The percent signs are required because they indicate that the table name to open is stored in the v_table_name variable. If the percent signs are omitted, the script attempts to open a table called "v_table_name".

Using multiple dialog boxes to gather required input

You want to create a separate dialog box for each value that the script user must enter.

You use a single prompt string in each instance of the ACCEPT command. The script generates separate dialog boxes for specifying each of the following:

  • a table name
  • a field on which to sample
  • a sampling interval
  • a random start value
ACCEPT "Enter the name of the table to analyze" TO v_table_name 
OPEN %v_table_name% 
ACCEPT "Select the field to sample" FIELDS "N" to v_field_to_sample 
ACCEPT "Enter the sampling interval" TO v_sampling_interval 
ACCEPT "Enter the random start value" TO v_random_start_value 
SAMPLE ON %v_field_to_sample% INTERVAL v_sampling_interval FIXED v_random_start_value RECORD TO Sample_output OPEN

When the script runs

  1. The first dialog box prompts for the table name.
  2. The second dialog box, with FIELDS "N" , prompts for a field selection from a drop-down list of numeric fields.
  3. The third dialog box prompts for the interval value.
  4. The fourth dialog box prompts for the random start value.

Using a single dialog box with multiple prompts to gather required input

You want to create a single dialog box for all values that the script user must enter.

You use multiple prompts separated by commas in the ACCEPT command to ask the user for multiple input values. The same dialog box contains prompts for the start date and the end date of a date range:

ACCEPT "Specify a start date:" TO v_start_date, "Specify an end date:" TO v_end_date

Remarks

Interactivity

Use ACCEPT to create an interactive script. When the ACCEPT command is processed, the script pauses and a dialog box is displayed that prompts the user for input that Analytics uses in subsequent processing.

You can create separate dialog boxes that prompt for one item at a time, or you can create one dialog box that prompts for multiple items.

DIALOG versus ACCEPT

The DIALOG command allows you to create a more advanced interactive dialog box that can have one or more of the following types of controls:

  • text box
  • check box
  • radio buttons
  • drop-down list of customized values
  • project item list

You also have the flexibility to customize the layout of the dialog box. For more information, see DIALOG command.

Codes for project item categories

Use the following codes to specify the category of project item to display in a drop-down list.

Project categories

Code

Category

xf

Tables

xb

Scripts

xi

Indexes

xr

Views and reports

xw

Workspaces

Field categories

Code

Category

C

Character fields

N

Numeric fields

D

Datetime fields

L

Logical fields

Variable categories

Code

Category

c

Character variables

n

Numeric variables

d

Datetime variables

l

Logical variables

Input data type

ACCEPT stores the user input in one or more character variables. If you need numeric or datetime input, you can use the VALUE( ) or CTOD( ) functions to convert the contents of a character variable to a numeric or datetime value:

SET FILTER TO BETWEEN(%v_date_field%, CTOD(%v_start_date%), CTOD(%v_end_date%))

In the example, the start and end dates for this filter are stored as character values. They must be converted to date values in order to be used with a date field that uses a Datetime data type.

Enclosing the variable name in percent signs (%) substitutes the character value contained by the variable for the variable name. The CTOD( ) function then converts the character value to a date value.

Position of the ACCEPT command

It is good practice to place all ACCEPT commands at the beginning of a script, if possible. If you ask for all input at the beginning, the script can then run unimpeded once the user enters the necessary information.

Note

You cannot use the ACCEPT command inside the GROUP command.