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.
- A combination of Key fields can be used to prevent users from adding more than one Record for that combination.
- A Single Selection field which is the unique Key in a Form will prevent users from adding a Record where the same option is selected more than once.
- A Reference field which is the unique Key in a Form will prevent users from adding a Record where the same referenced Record is selected more than once.
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.
- A Key Field is Required and cannot be hidden from data entry.
- You cannot set Relevance rules to a Key field.
- 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.
- 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.
- 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.
- 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.