Parsware
All articles

How-tos

How to make a field required or read-only

Make a field required, make another read-only on one form, and watch a save refused with the field named. How-to video H018, step by step.

A bright cover reading "How-to · H018: Required or read-only", with "A save refused, with the field named" under it, the steps Field → Form → Read-only → Refused, and two screens from the video.

How-to H018 · 1 min 46 s. A complete tutorial: every click the video makes, where each setting lives, what it does and doesn't protect, and how it is stored. Every picture is a frame of the video.

Some fields must be filled in, and some should only be looked at. In this tutorial you make Contact name required on every opportunity, make Probability read-only on one form, and watch the platform refuse a save that leaves the contact empty.

Setting Where it is set What it does
Required on a field The table's Fields Every form asks for it, unless a form says otherwise.
Required on a placement One form That form alone asks for it, or doesn't.
Read-only on a placement One form That form shows the value but doesn't let anybody type in it.

Before you start

Part 1: Make a field required

  1. Open Solutions, then Sales Tracker, select Tables and open Opportunity. The Required column in the Fields list shows that only Name must be filled in.

  2. Select Contact name. Its panel opens.

  3. Tick Required.

    Read the note under it. Required is checked on forms, not in the database: a record created another way (an import, an API call, a script) can still leave it empty. The only field the server always insists on is the primary Name, because every list and lookup shows a record by it.

  4. Select Save.

Contact name is now required on every form, unless a form says otherwise.

Part 2: Make a field read-only on a form

Read-only belongs to a form, not to the field: the same field can be typed on one form and only shown on another.

  1. Select Forms and open Information.
  2. Select Contact name on the form. Its Required box is already ticked: the placement follows the field.
  3. Select Probability. People shouldn't type it, because it will follow the sales stage. Tick Read-only.
  4. Select Save.

The form designer for Information, with Probability selected and Read-only ticked in its properties.

A form can also tick or untick Required for itself alone, on any placement. A placement stores it only when it differs from the field's own setting, so a field you make required later still reaches every form that never said otherwise.

Part 3: Try it

  1. Open Sales Test's address, open Sales Tracker and select New.
  2. Look at the form. Contact name has a red star. Probability is dimmed: it can be read, but not typed in.
  3. Type a name and leave the contact empty. Select Save.

The record isn't saved. The form names the field that is missing: This field is required.

A new opportunity in the app, with Contact name marked by a red star and the message This field is required. under it, and Probability dimmed.

  1. Type the contact's name and select Save again. This time the record is saved.

The settings as text

The field's own Required is on the table's document:

{ "logicalName": "tsp_contactname", "displayName": "Contact name", "dataType": "Text", "maxLength": 100, "isRequired": true }

Read-only, and any form-only Required, are on the form's document, beside the field's placement:

{
  "title": "General",
  "fields": [
    { "field": "tsp_name" },
    { "field": "tsp_contactname" },
    { "field": "tsp_salesstage" },
    { "field": "tsp_probability", "readOnly": true }
  ]
}

Contact name's placement says nothing, so it follows the field and is required. To relax it on this form alone, the placement would say "required": false.

Making a value that nobody types

Probability is read-only on this form, so something else has to fill it in: a business rule on the form, or a plugin step that runs when the record is saved. Both are written in BS Lang, and both compare an option-set field with the option's number, which you read on the option set after saving it. Plugin steps, before and after a save shows how.

If something goes wrong

  • The star and the check don't appear. Make sure you ticked Required on the field (or on its placement: select the field itself, not its section), and saved.
  • An import left a required field empty. That is expected: Required is a form rule. Check the data at the source, or validate it with a plugin step.
  • A read-only field still shows an old value. Read-only stops people editing it on this form. A value already on the record is shown and kept. To hide it, take it off the form.

What you built

A required field that can't be skipped on a form, and a read-only one that can't be typed in. Each is set once and obeyed everywhere that form is used.

Read more

Is there a task you would like to see done step by step? Tell us. parsware.com/contact