Key

Keys are very important properties in ActivityInfo and they help you build flexible Forms. A Key helps you uniquely identify a Record. When you assign the Key property to a field you identify a Record, you individualize it. This is very useful when you want to reference a specific field in a Form.

When a Form has a Serial Number field, it automatically becomes the Key field of the Form and no more Keys can be added. This is useful and preferable in Protection cases when you don't want to reveal information when you refer to a Record of a Form.

If you haven't added a Serial Number in your Form then it is advised that you select another field to define as the Key to your Form.

Examples of Key uses

  • Keys are necessary to allow users to import Records to a Subform or to Reference another Form. This is because users need to link Records by using a common field (i.e. the Key or the Serial Number).
  • When you make a Date/Week/Month or any other time-related field a Key field you can use it to add Locks on Records. This is useful for Monthly or Weekly Reporting Subforms for example.
  • A combination of Key fields can be used to prevent users from adding more than one Record for that combination (e.g. a Name and a Surname).
  • Keys prevent users from adding duplicate Records. For example, a Single Selection field which is the Key in a Form will prevent users from adding a Record where the same option is selected more than once. You can create combination of Keys too.

Attention!

  • If you add a Serial Number field in your Form, this field automatically becomes the Key field for your Form and you cannot add other Keys.
  • If a Form uses multiple keys, the first Key field will be marked as  Required and this cannot be hidden from data entry. You cannot set Relevance rules to this field either.
  • If a Key field is left empty during data entry and the field is referenced in another Form, the field value will appear as "(Blank)" in the selection list of that Form.
  • Key fields allow you to update records during importing.
  • Quantity, Calculated, Geographic Points, Multiple Selection, Multi-line Text & Attachments fields cannot be Key fields.
  • You can add up to 10 Keys in a Form (or only one Serial Number).

Examples

In this example, we make a Single Selection field a Key field for our Form. Then we create another Form which refers to it to allow users to select one of the cities for which there are available Records and link their Records to it.

A Key can be also used to inform users that there is a duplicate for a specific combination of fields and prevent them from adding the same Record.

In the example below, the "Date of distribution" and the "School Name" are Key fields. When users try to add a Record and add the same Date and School Name as in another Record , they get an error.

A Key can prevent users from adding a duplicate Record for the same option in a Single Selection field.

In the example below, the "Select city" Single Selection field is a Key field. When users try to add a Record for an option that has already been used in another Record, they get an error.

A Key can be used to allow you to add a Lock to a Form or Subform to prevent users from adding Records for a specific period.

In the example below, the "Date of reporting" Date field is a Key field. There is a Lock that prevents users from adding Records for January 2020. When users try to add a Record for a Date in January they get an error.