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

    Interface TypeDocHidden_IFieldChoice

    Manages a choice field.

    Inherits core field functionality from Field, including:

    const { form } = tisa;
    const { myField } = form.field;

    // get the selected option
    const selectedOption = myField.value;
    console.log(selectedOption);

    // set the selected option
    myField.value = "option1";
    interface TypeDocHidden_IFieldChoice {
        description: string;
        hidden: boolean;
        internalName: string;
        onChange: (func: OnChangeDelegate) => void;
        originalValue: any;
        readOnly: boolean;
        required: boolean;
        setValue: (value: any, disableTriggerOnChange?: boolean) => Promise<void>;
        title: string;
        typeAsString: FieldType;
        value: any;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    description: string

    Gets or sets the description of the field. The description is displayed in the field header. If set, it overrides the default description in SharePoint for the field.

    const { form } tisa;
    const { myField } tisa.form;
    myField.description = "My Field Description";
    hidden: boolean

    Gets or sets a value that specifies whether the field is hidden on form. If the field is hidden, the field is not displayed on the form, but can be accessed programmatically.

    const { form } tisa;
    const { myField } tisa.form;
    myField.hidden = true;
    internalName: string

    Gets the internal name that is used for the field.

    originalValue: any

    Gets original field value before any changes. This value is not updated when the field value is changed.

    const { form } tisa;
    const { myField } tisa.form;
    console.log(myField.originalValue);
    readOnly: boolean

    Gets or sets a value that specifies whether the value of the field is read-only. If the field is read-only, the value of the field cannot be changed in the UI, but can be changed programmatically using the value property or the setValue method.

    const { form } tisa;
    const { myField } tisa.form;
    myField.readOnly = true;
    required: boolean

    Gets or sets a value that specifies whether the field requires a value. If the field is required, the value of the field must be set before the form can be saved.

    const { form } tisa;
    const { myField } tisa.form;
    myField.required = true;
    setValue: (value: any, disableTriggerOnChange?: boolean) => Promise<void>

    Sets a field value and waits for the value to be evaluated or rendered in the UI. Also allows disabling the trigger onChange event.

    Type declaration

      • (value: any, disableTriggerOnChange?: boolean): Promise<void>
      • Parameters

        • value: any

          the value you want to set in the field

        • OptionaldisableTriggerOnChange: boolean

          (optional) disables the onChange event from being raised on the field

        Returns Promise<void>

    const { form } tisa;
    const { myField } tisa.form;
    // sets a field value and waits for the value to be evaluated or rendered in the UI
    await myField.setValue(1);
    // sets a field value and does not trigger the OnChange event
    await myField.setValue(1, true);
    title: string

    Gets or sets the title of the field. The title is displayed in the field header. If set, it overrides the default title in SharePoint for the field.

    const { form } tisa;
    const { myField } tisa.form;
    myField.title = "My Field";
    typeAsString: FieldType

    Gets the type of the field.

    const { form } tisa;
    const { myField } tisa.form;
    console.log(myField.typeAsString);
    value: any

    Gets or sets the value of the field. Optionally, the setValue method can be used for advanced setting value. If value is set, the onChange event is triggered.

    const { form } tisa;
    const { myField } tisa.form;
    myField.value = "My Value";

    Events

    onChange: (func: OnChangeDelegate) => void

    The event is triggered whenever the field value changes. The event can be suppressed by calling the setValue method with the disableTriggerOnChange parameter set to true.

    Type declaration

    const { form } tisa;
    const { myField1, myField2 } tisa.form;
    // copies the value of field1 when changed to field2 and logs the old and new values
    myField1.onChange((value, { oldValue })=>{
    myField2.value = value;
    console.log(`${oldValue} -> ${value}`);
    });