Key

Overview

The "Key" property provides a way to label records in the user interface, enforce record uniqueness during data entry, and help users look up related records during data entry for a reference field.

Behaviour

Key fields play several roles in ActivityInfo:

  • Key fields provide a way to label records in the user interface.
  • Key fields enforce record uniqueness during data entry
  • Key fields help users to look up related records during data entry
  • Key fields are used to match related records when importing
  • Key fields are used to match existing records to update during importing
  • Key fields indicate which to which fields date-based locks apply

Labeling records

When selecting or deleting records, the records are labeled in the user interface using the values of the key fields:

If no key field is specified, the Record ID is used to label the record.

Enforcing uniqueness

ActivityInfo will not allow adding a record with the same of key field as an existing record.

If there are multiple key fields, then the combination of key field values must be unique. For example, if you have two key fields “First Name” and “Last name”, then “John Smith” and “John Smith” are considered duplicates, but “John Brown” and “John Smith” and “Bill Smith” are different combinations and can all be added to the form.

If you try to add a record with the same combination of key fields, an error message is displayed:

Checking for duplicates requires access to the existing records. If two users are working offline and are disconnected from the internet, it will be possible for them add duplicate records. Both copies of the records will be synchronized to the server when the users connect.

Looking up records in reference fields

When you add a Reference Field to another form, Key fields are used to display the list of records to choose from.

If you designate multiple fields as Key Fields, then ActivityInfo will provide a cascading set of dropdowns.

Labeling reference values in the table view

When viewing a form with a reference field in the Table View, the values of the key fields are used to label the related record.

Indicate which fields to which date-range locks should be applied

When you add a date-range lock, it will only apply to forms that have a date-like field designated as a Key Field. This includes:

  • Date
  • Month
  • Week
  • Fortnight

In many cases, you may want to apply a lock based on a date that is not a key field. In these cases, you should a rule-based lock instead.

Optional Key Fields

The first Key Field in a form must be required.

However, subsequent Key Fields can be optional. This can be useful if a field is part of a record’s unique identifier, but only some of the time.

Supported Field Types

The following field types may be designated as Key Fields

  • Serial number
  • Fortnight
  • Barcode
  • Date
  • User
  • Reference
  • Month
  • Text
  • Week
  • Fortnight
  • Single Selection

Limits

Each form can have a maximum of 10 Key fields.

A Serial Number Field is always the only Key Field. A Serial Number field cannot be combined with other Key Fields.

Example

The following table provides a few example of forms and common choices for Key Fields.

Form Key Field(s) Notes
Province Name (Text)
Territory

Name (Text)

Province (Reference to Province)

NFI Distribution

Date of Distribution (Date)

Location (Reference to Village)

Unless your programme is planning on providing multiple distributions to the same place on the same day, these two fields are good natural keys.
Beneficiary Email Address (Text) An email would be a good natural key if your assistance is delivered digitally, as all beneficiaries can be expected to have an email address.
Beneficiary

First Name (Text)

Last Name (Text)

Date of Birth (Text)

In many cases, you’ll need a combination of Key fields to identify beneficiaries.
Activity

Type of Activity (Single Select)

Date of activity (Date)
Partner (Reference to Partner)

Next item
Duplicating a Form