Administer > Database administration > Data persistence > Record retrieval > Multiple-record functions > Add multiple records using a variable value

Add multiple records using a variable value

Applies to User Roles:

System Administrator

Example:  Duplicate all "contacts" records with a value of advantage. Include the same information in each record, except for changing the Company to NewAdvantage, creating sequential values, and creating a Unique key for each record.

Since Contact Name ( is a Unique key and Employee ID ( is a No Duplicates key in the contacts file, you must assign unique and values to the new records. For additional information about key type definitions, see the related topics. For this example, suffix the values in the new records with sequential numbers, starting with 1000 (1000, 1001, and so on.)

Note: Mass Add processing statements reference $file to access fields on records in the list. For example, name in $file or 1 in action in $file.

To add records using a variable value:

  1. Open the form in Database Manager. Ensure that you select the Administration Mode check box. For this example, open the following form: contacts. A blank contacts form opens.
  2. Enter the desired value in the Location field.

    For this example, type North America, and then click Search.

    Database Manager performs the equal to search and displays the Record List of matching record(s), if any. If the query produces no matching records, Service Manager displays a message.

  3. To display the Mass function buttons, use a query that returns more than one record.

    Select Mass Add from the tool bar to start the process of duplicating the records shown in the Record List.

    Database Manager displays the Mass Add/Update Instruction screen.

  4. Type the following assignment statement in the Instructions to be executed ONCE at the beginning of Mass Add/Update input field.

    $sequential.number=1000Sets the start point for the variable at 1000 and will be executed only once for the entire function.

  5. Enter the following statements on the Instructions for action on EACH RECORD input fields:

    StatementPurpose in $file=“NewAdvantage”+str($sequential.number)Sets the User Id to NewAdvantage with a sequential number as a suffix.
    $sequential.number+=1Causes one (1) to be added to all future numbers created from this variable. in $ in $file + “ ” + in $fileMakes the contact name the same as the first and last name.

  6. Click Execute.

    Database Manager performs the Mass Add function in the foreground. Your session is devoted to the add task until it is completed. If you are updating a large number of records, this can take a while.

    Upon completion, Service Manager returns terminal control to you and displays the following message:<nnn>records added to the contacts file where nnn is the number of records added.

  7. Click View Messages to check the messages for errors.
    • A blue icon indicates a required action.
    • A yellow icon indicates an informational or warning message.
    • A red icon indicates an error message.
  8. Close the Messages window to return to the contacts form.

The topics below comprise an example of how to use multiple-record functions. Follow the steps in this order. If you skip a step, the example will not work.

  1. Add multiple records using a literal value
  2. Add multiple records using a variable value
  3. Update multiple records using a literal value
  4. Update multiple records using a variable value
  5. Avoid invalid duplicate or null key errors
  6. Delete multiple records

Related topics

Adding multiple records
Multiple-record functions

Add multiple records using a literal value
Determine the number of records in a record list
Open a record using Database Manager

Key type definitions
Service Manager Programming