Defining Key fields

The following section describes how the Key property works and presents how to define one or more fields as Key fields when designing a Form. It also describes how you can prevent users from adding duplicate Records by defining Key fields (i.e. key points of information that should not be repeated).

Keys are very important properties in ActivityInfo and they help you build flexible Forms. The Key property is used to uniquely identify a Record. 

This is very useful for a variety of cases as a Key allows you to easily reference a specific field in a Form. 

Examples of cases where Key fields are used:

  • A Key field is necessary to allow users to import Records to a Subform. A Key field needs to be identified in the Parent Form to allow you to link the Records you plan to import to a Subform to the correct Record of the Parent Form.
  • A Key field allows you to easily Reference the Record of another Form. This can be the Serial Number of a Record or a specific field which has been defined as a Key field.
  • 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 more easily.
  • 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. A combination of Key fields can be used to prevent users from adding more than one Record for that combination.

If you add a Serial Number in your Form, then this becomes the Key of the Form automatically. To use the Serial Number and make it easier to recognise, you can customize it using a Text field or a Single Selection field. 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.

Key points about Keys:

  • 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 add 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 1 Serial Number).
How to define a Key field
  • In the Form Design page, click on the field you want to make Key.
  • In the Field Card editor, check the box next to "Key".
  • Click on "Done" to save the field.
  • When you finish adding fields, click on "Save" to save the Form.

A field that is defined as Key, appears with the label "KEY" in the Form Designer.

How to use a combination of Key fields to prevent users from adding duplicate Records
  • In the Form Design page select the fields which will act as Key fields by checking the Key property to make them keys.
  • Users will get an error if they add a Record with information that has been already added for these fields.
How to use a Single Selection field as a Key to prevent users from adding duplicate Records
  • In the Form Design page select the Single Selection field which will act as a Key by checking the Key property.
  • Users will get an error if they select the same option.