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

    The user field type is used to display a user or a list of users on a SharePoint item.

    Inherits core field functionality from Field, including:

    • get or set the value of the field (value, setValue (optional)), user values can be set by Id, login name (UPN or claim token), or a IPrincipalInfo object.
    • set common field properties (readOnly, hidden, required, title, description)
    • define an event onChange that is triggered whenever the field value changes.
    const { form } = tisa;
    const { myField } = tisa.form.field;

    // set single user by Id
    myField.value = 1;
    // set single user by login name (upn or claim token, async operation)
    await myField.setValue("user1@example.com");

    // set multiple users by Id
    myField.value = [1, 2, 3];
    // set multiple users by login name (upn or claim token, async operation)
    await myField.setValue([ "user1@example.com", "user2@example.com", "user3@example.com"]);

    // clear field value
    myField.value = null;
    await myField.setValue(null);

    // reset field value to original value
    myField.value = myField.originalValue;

    Hierarchy (View Summary)

    Implements

    • IFieldUser
    Index

    Properties

    description: string

    Gets or sets the description of the field. The description is displayed below the input. If set, it overrides the default description coming from SharePoint. Supports resource keys with the RESX. prefix (e.g. "RESX.MyFieldDescription"). The key is resolved from the form's Resources translation table.

    const { form } = tisa;
    const { myField } = tisa.form.field;
    myField.description = "My Field Description";
    myField.description = "RESX.MyFieldDescription"; // resolved from Resources
    hidden: boolean

    Gets or sets whether the field is hidden.

    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.field;
    console.log(myField.originalValue);
    readOnly: boolean

    Gets or sets whether the field is read-only.

    required: boolean

    Gets or sets whether the field requires a value.

    title: string

    Gets or sets the title (label) of the field. The title is displayed in the field header. If set, it overrides the default title coming from SharePoint. Supports resource keys with the RESX. prefix (e.g. "RESX.MyFieldTitle"). The key is resolved from the form's Resources translation table.

    const { form } = tisa;
    const { myField } = tisa.form.field;
    myField.title = "My Field";
    myField.title = "RESX.MyFieldTitle"; // resolved from Resources
    typeAsString: FieldType

    Gets the type of the field.

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

    Gets or sets the user(s) by Id. User(s) can be set also by native SharePoint field value format or IPrincipalInfo object. User returns IPrincipalInfo object or IPrincipalInfo object array, if multiple on field is supported. For setting user(s) by login name (UPN or claim token), use the setValue method.

    • Getting user value in onInit event is supported only with awaiter.
    • Setting user value using LoginName should be performed by setValue.
    // usage in onInitComplete event (allow synchronous operations with user field)

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

    // get user field value
    const value = myField.value;
    console.log(value);

    // set single user by Id
    myField.value = 1;
    // set single user by User object
    myField.value = { Id: 1, LoginName: "user1@example.com", Title: "Name of User 1" };
    // set single user by native SharePoint field value format
    myField.setValue("1#;Name of User 1");
    // set multiple users by Id
    myField.value = [1, 2, 3];
    // set multiple users by User objects
    myField.value = [{ Id: 1, LoginName: "user1@example.com", Title: "Name of User 1" }, { Id: 2, LoginName: "user2@example.com", Title: "Name of User 2" }, { Id: 3, LoginName: "user3@example.com", Title: "Name of User 3" }];
    // set multiple users by native SharePoint field value format
    myField.setValue(["1#;Name of User 1", "2#;Name of User 2", "3#;Name of User 3"]);

    // clear user field value
    myField.value = null;
    myField.value = [];

    // reset user field value to original value
    myField.value = myField.originalValue;
    // usage in onInit event (only asynchronous operations with user field are allowed)

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

    // get user field value
    const value = await myField.value;
    console.log(value);

    // set single user by login name (upn or claim token)
    await myField.setValue("john.doe@example.com");
    const newValue = await myField.value;
    console.log(newValue);

    Methods

    • gets field property from tisaFields (TiSaProvider.tsx)

      Parameters

      • property: string

      Returns any

    • sets field property in tisaFields (TiSaProvider.tsx)

      Parameters

      • property: string
      • value: any

      Returns void

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

      Parameters

      • value: string | number | string[] | number[] | IPrincipalInfo | IPrincipalInfo[]

        the value to set

      • OptionaldisableTriggerChange: boolean

        when true, the onChange event is not raised

      Returns Promise<any>