Examples menu

Examples / Workflows

Agent-only form fields

Mark a field as the agent's, and any value a person submits for it is thrown away, so only the agent can set it.

Some fields must come from the agent and nobody else: a priority that routes work, a flag that holds something for review, a score. uagAuthoritative: "true" marks them. Whenever a submission is created or updated through the UAG, any value the browser sent for those fields is thrown away first, so the only value saved is the agent's.

This form leaves the two fields open so you can try. Type a summary, choose a priority, and submit: the saved submission comes back without your values, and the agent's appear a few seconds later.

This applies to submissions sent through the UAG. To also protect the fields from someone who sends a submission straight to Form.io, the action can act with an agent role of its own; see the developer docs.

Turn it on

json
{
  "title": "Example: Agent-only form fields",
  "name": "exampleAgentOnlyFields",
  "path": "example-agent-only-fields",
  "type": "form",
  "display": "form",
  "tags": [
    "uag"
  ],
  "properties": {
    "description": "A message whose priority and summary only the reviewing agent may set."
  },
  "components": [
    {
      "type": "textarea",
      "key": "message",
      "label": "Message",
      "input": true,
      "rows": 4,
      "validate": {
        "required": true
      }
    },
    {
      "type": "content",
      "key": "reviewCriteria",
      "label": "Criteria",
      "input": false,
      "html": "<p>You review messages sent to a team. Read <code>message</code>. Write <code>summary</code>: one sentence, under 20 words, saying what the sender wants. Set <code>priority</code> to <code>urgent</code> if work is stopped or a deadline is within two days, <code>low</code> if nothing is blocked, and <code>normal</code> otherwise.</p>",
      "properties": {
        "uag": "review",
        "uagField": "criteria",
        "uagEngine": "agent"
      }
    },
    {
      "type": "panel",
      "key": "review",
      "title": "Only the agent's values are kept",
      "input": false,
      "components": [
        {
          "type": "radio",
          "key": "priority",
          "label": "Priority",
          "input": true,
          "values": [
            {
              "label": "Low",
              "value": "low"
            },
            {
              "label": "Normal",
              "value": "normal"
            },
            {
              "label": "Urgent",
              "value": "urgent"
            }
          ],
          "properties": {
            "uag": "review",
            "uagAuthoritative": "true",
            "uagAgentDecides": "true"
          }
        },
        {
          "type": "textfield",
          "key": "summary",
          "label": "Summary",
          "input": true,
          "properties": {
            "uag": "review",
            "uagAuthoritative": "true"
          }
        }
      ]
    },
    {
      "type": "button",
      "key": "submit",
      "label": "Submit",
      "action": "submit",
      "input": true
    }
  ]
}

Try it

Samples:
Example: Agent-only form fields

Read about it in the developer docs