Code

Overview

A Field Code is a short, alphanumeric identifier for Fields that can be used in Formulas and the API.

Using codes in Formulas

When using the Formula editor, you can see the Code value of the available Fields, which helps to identify which Field to use for respective Formulas. Therefore, filling out the Code Field is highly recommended, especially when working with API.

For example, you could reference Forms with or without Code fields, the difference would look something like this:

  • Using Code fields: CONCAT(Rightsholder.first_name, "-", middle_name, "-", Rightsholder.last_name)
  • Without Code fields: CONCAT( clchw8tm7t8nb0ua.[First name], "-", [Middle name], "-", clchw8tm7t8nb0ua.[Last name])
Formula editor without Code field values
Formula editor without Code field values
Formula editor with Code fields filled out
Formula editor with Code fields filled out

For more information, see Using the Formula editor.

Using codes in the API

Assigning Field Codes also makes it easier to work with the API. You can use the Field Code, rather than Field Id, for example, when submitting updates through the process described in the Update Records API article.

For example, you could add a new Record to the Rightsholder Form above using the following command line:

curl -X POST https://www.activityinfo.org/resources/update \
  -u anything:APITOKEN \
  -H 'Content-type: application/json' \
  --data-binary @- << EOF
{
  "changes": [
    {
      "formId": "cdznrnclh1x8y8s7",
      "recordId": "ci8l8aqlh1x8y8s8",
      "fields": {
        "first_name": "Kofi",
        "last_name": "Annan"
     }
  ]
}
EOF
Next item
Design a Form