f365.field, accessing form fields

Read and write field values, toggle visibility/enabled/required, listen for events, focus, blur, validate.

f365.field(internalName) returns a property-style FieldHandle for the named field. Use it to read or write the value, toggle UI state, listen for events, and trigger lifecycle methods.

Looking up a handle

PropertyDescription
f365.field(name)Throws if the field is unknown. Use when you know the field exists.
f365.tryField(name)Returns null if unknown. Safe for optional fields.
f365.fields()Returns a map of every field name to its handle. Useful for bulk operations.

Properties

PropertyDescription
valueGet / set the field value. Type depends on the field, string for Text, number for Number, string[] for MultiChoice, { id, label, path? } for Managed Metadata (an array of them when several terms are allowed; null or [] when empty), etc. A Managed Metadata field accepts a term ID, Label|ID, { id, label }, a label that matches exactly one term, or an array of these.
visible / hiddenToggle visibility. visible = false hides the field; hidden = true equivalent. Survives until next change to visibleIf.
enabled / disabledToggle the enabled state. Symmetric to visible/hidden. A disabled field still saves its value. enabled = true only re-enables what a script disabled; a field greyed by an Enable if rule stays under that rule.
requiredMark the field required (or not). Adds the red asterisk and enforces on submit.
readOnlyLock the value from editing; it is still saved. Dropdowns, radios and checkboxes have no read-only mode, so they are disabled instead (still saved).
label / description / placeholderOverride the displayed copy. Useful when copy depends on form state.

Methods

Read and write the value

const v = f365.field('Title').value;
f365.field('Title').value = 'New title';

Listen for changes

f365.field('Department').on('change', (next, prev) => {
  console.log('Department changed', { next, prev });
});

Focus the field after a delay (e.g. after revealing it)

f365.events.onChange('NeedsReason', (need) => {
  if (need) {
    f365.field('Reason').visible = true;
    f365.setTimeout(() => f365.field('Reason').focus(), 100);
  }
});

Inline validation

f365.field('ABN').on('validate', (value) => {
  if (!value) return;
  if (!/^\d{11}$/.test(value)) return 'ABN must be 11 digits.';
});

Clear the field

f365.field('Notes').clear();

Methods reference

PropertyDescription
on(event, handler)Subscribe to "change", "blur", "focus", or "validate".
focus() / blur()Programmatic focus management.
clear()Reset to empty/null.
reset()Reset to the value the field had at form load.
validity()Returns { valid: boolean, message?: string } for the current value.
scrollIntoView()Scroll the form so this field is visible. Useful for surfacing errors.
el()Get the underlying DOM input element. Use sparingly, prefer the typed properties above.

Typed handles

asLookup(), asUser(), asTaxonomy() return narrowed handles with type-specific properties (e.g. filter on Lookup, setToCurrentUser() on Person, setTermSet() and termsByLabel() on Managed Metadata). They return null when the underlying field isn't of that type, always check before use.

Related articles