TreeINFO-For-M365 documentation
    Preparing search index...

    Hierarchy

    • BaseService<FormCustomizerContext>
      • Form

    Implements

    • IFormService
    Index

    Properties

    field: Dictionary<IFieldService>

    Provides access to form fields.

    const value = tisa.form.field.myField1.value;
    console.log(value);

    const { myField1 } = tisa.form.field;
    myField1.readOnly = true;
    group: Dictionary<IGroupService>

    Provides access to form groups.

    const { G_Supplier } = tisa.form.group;
    G_Supplier.hidden = true;
    isDisplayForm: boolean

    Gets a value indicating whether the form does not allow to edit the item.

    const { form } = tisa;
    if (form.isDisplayForm) {
    // your code...
    }
    isEditableForm: boolean

    Gets a value indicating whether the form is currently editable. The isEditableForm property is true when either isNewForm or isEditForm is true.

    const { form } = tisa;
    const { myField1, myField2, myField3 } = tisa.form.field;
    if (form.isEditableForm) {
    // set read-only property for some fields
    myField1.readOnly = true;
    myField2.readOnly = false;

    // set required property for some fields
    myField2.required = true;

    // set value for some fields
    myField3.value = "test";
    }
    isEditForm: boolean

    Gets a value indicating whether the form allows to edit the item.

    const { form } = tisa;
    if (form.isEditForm) {
    // your code...
    }
    isNewForm: boolean

    Gets a value indicating whether the item does not yet exist and the form allows to fill in its metadata.

    const { form } = tisa;
    const { myField1, myField2 } = tisa.form.field;
    if (form.isNewForm) {
    // copy value of field1 to field2 when it changes
    myField1.onChange((value) => {
    myField2.value = value;
    });
    }
    isTaskForm: boolean

    True if the form displays a task to complete.

    const { form } = tisa;
    if (form.isTaskForm) {
    // your code...
    }
    print: Print

    Provides print template functionality for the current form.

    const { form } = tisa;

    // Open a print template in a new window
    await form.print.show("ContractCoverSheet");

    // Open with debug box showing all form data
    await form.print.show("TestTemplate", true);

    Accessors

    • get fieldValues(): Dictionary<any>

      Gets the values of all fields in the form. The values are stored in a dictionary with the field internal name as the key and the field value as the value.

      Returns Dictionary<any>

      const { form } = tisa;
      const fieldValues = form.fieldValues;
      console.log(fieldValues);
    • get readOnly(): boolean

      Gets or sets the editability of the form. Locks all editable fields when set to true.

      Returns boolean

      const { form } = tisa;
      form.readOnly = true;
    • set readOnly(value: boolean): void

      Gets or sets the editability of the form. Locks all editable fields when set to true.

      Parameters

      • value: boolean

      Returns void

      const { form } = tisa;
      form.readOnly = true;

    Methods

    • Closes the form.

      Returns Promise<void>

      console.log("Form is about to get closed");
      await tisa.form.close();
      console.log("This message won't be logged since the form has already been closed.");
    • Saves the form data.

      By default the form stays open after saving (redirect is false). On a new form, saving without redirect creates the item in SharePoint and automatically switches the form to edit mode — subsequent operations (e.g. starting a workflow) can reference the newly created item.

      Returns true if the form was valid and saved successfully, false if validation failed. Use the return value to conditionally continue after save (e.g. start a workflow).

      Parameters

      Returns Promise<boolean>

      true if the form was saved, false if validation failed.

      // Save and close the form
      await tisa.form.save({ redirect: true });
      // Code here will not execute — the form has already been closed.
      // Save without closing — item is created and form switches to edit mode.
      // Subsequent API calls (e.g. workflow) have access to the new item.
      await tisa.form.save();
      await tisa.workflow.start("Approval");
      // Check if the form is valid before continuing
      const saved = await tisa.form.save();
      if (!saved) return; // form is invalid, stop here

      await tisa.workflow.start("Approval");
    • Sets the active form definition by name. The name must match one of the CustomFormDefinitions defined in the form JSON config.

      Can only be called during onFormInit. Throws if called after init or if the name is not found.

      Parameters

      • name: string

        Name of the custom form definition to activate.

      Returns void

      async function onFormInit() {
      const { form } = tisa;

      if (form.isDisplayForm) {
      form.setFormDefinition("DisplayForm");
      } else if (form.isNewForm) {
      form.setFormDefinition("ReceivedMessage");
      }
      }
    • Validates the form data.

      Returns Promise<boolean>

      whether the form data is valid.

      const formIsValid = await tisa.form.validate();

      if (formIsValid) console.log("Form is valid.");
      else console.log("Form is invalid.");