Skip to content

Custom Fields

albert.resources.custom_fields

FieldType

Bases: str, Enum

The type (list or string) of the custom field

Attributes:

Name Type Description
LIST
STRING
NUMBER

LIST

LIST = 'list'

STRING

STRING = 'string'

NUMBER

NUMBER = 'number'

ServiceType

Bases: str, Enum

The service type the custom field is associated with

Attributes:

Name Type Description
INVENTORIES
LOTS
PROJECTS
TASKS
USERS
PARAMETERS
DATA_COLUMNS
DATA_TEMPLATES
PARAMETER_GROUPS

INVENTORIES

INVENTORIES = 'inventories'

LOTS

LOTS = 'lots'

PROJECTS

PROJECTS = 'projects'

TASKS

TASKS = 'tasks'

USERS

USERS = 'users'

PARAMETERS

PARAMETERS = 'parameters'

DATA_COLUMNS

DATA_COLUMNS = 'datacolumns'

DATA_TEMPLATES

DATA_TEMPLATES = 'datatemplates'

PARAMETER_GROUPS

PARAMETER_GROUPS = 'parametergroups'

FieldCategory

Bases: str, Enum

The ACL level of the custom field

Attributes:

Name Type Description
BUSINESS_DEFINED
USER_DEFINED

BUSINESS_DEFINED

BUSINESS_DEFINED = 'businessDefined'

USER_DEFINED

USER_DEFINED = 'userDefined'

EntityCategory

Bases: str, Enum

The entity category of the custom field. Only some categories are allowed for certain services

Attributes:

Name Type Description
FORMULAS
RAW_MATERIALS
CONSUMABLES
EQUIPMENT
PROPERTY
BATCH
GENERAL

FORMULAS

FORMULAS = 'Formulas'

RAW_MATERIALS

RAW_MATERIALS = 'RawMaterials'

CONSUMABLES

CONSUMABLES = 'Consumables'

EQUIPMENT

EQUIPMENT = 'Equipment'

PROPERTY

PROPERTY = 'Property'

BATCH

BATCH = 'Batch'

GENERAL

GENERAL = 'General'

UIComponent

Bases: str, Enum

The UI component available to the custom field

Attributes:

Name Type Description
CREATE
DETAILS

CREATE

CREATE = 'create'

DETAILS

DETAILS = 'details'

CustomField

Bases: BaseResource

A custom field for an entity in Albert.

Returns:

Type Description
CustomField

A CustomField that can be used to attach Metadata to an entity in Albert.

Attributes:

Name Type Description
name str

The name of the custom field. Cannot contain spaces.

id str | None

The Albert ID of the custom field.

field_type FieldType

The type of the custom field. Allowed values are list and string. String fields cannot be searchable and are used to set uncontrolled metadata. List fields can be searchable and are used to set controlled metadata.

display_name str

The display name of the custom field. Can contain spaces.

searchable bool | None

Whether the custom field is searchable, optional. Defaults to False.

service ServiceType

The service type the custom field is associated with.

hidden bool | None

Whether the custom field is hidden, optional. Defaults to False.

lookup_column bool | None

Whether the custom field is a lookup column, optional. Defaults to False. Only allowed for inventories.

lookup_row bool | None

Whether the custom field is a lookup row, optional. Defaults to False. Only allowed for formulas in inventories.

category FieldCategory | None

The category of the custom field, optional. Defaults to None. Required for list fields. Allowed values are businessDefined and userDefined.

min int | None

The minimum value of the custom field, optional. Defaults to None.

max int | None

The maximum value of the custom field, optional. Defaults to None.

entity_categories list[EntityCategory] | None

The entity categories of the custom field, optional. Defaults to None. Required for lookup row fields. Allowed values are Formulas, RawMaterials, Consumables, Equipment, Property, Batch, and General.

ui_components list[UIComponent] | None

The UI components available to the custom field, optional. Defaults to None. Allowed values are create and details.

Show JSON schema:
{
  "$defs": {
    "AuditFields": {
      "description": "The audit fields for a resource",
      "properties": {
        "by": {
          "default": null,
          "title": "By",
          "type": "string"
        },
        "byName": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Byname"
        },
        "at": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "At"
        }
      },
      "title": "AuditFields",
      "type": "object"
    },
    "EntityCategory": {
      "description": "The entity category of the custom field. Only some categories are allowed for certain services",
      "enum": [
        "Formulas",
        "RawMaterials",
        "Consumables",
        "Equipment",
        "Property",
        "Batch",
        "General"
      ],
      "title": "EntityCategory",
      "type": "string"
    },
    "FieldCategory": {
      "description": "The ACL level of the custom field",
      "enum": [
        "businessDefined",
        "userDefined"
      ],
      "title": "FieldCategory",
      "type": "string"
    },
    "FieldType": {
      "description": "The type (list or string) of the custom field",
      "enum": [
        "list",
        "string",
        "number"
      ],
      "title": "FieldType",
      "type": "string"
    },
    "ServiceType": {
      "description": "The service type the custom field is associated with",
      "enum": [
        "inventories",
        "lots",
        "projects",
        "tasks",
        "users",
        "parameters",
        "datacolumns",
        "datatemplates",
        "parametergroups"
      ],
      "title": "ServiceType",
      "type": "string"
    },
    "Status": {
      "description": "The status of a resource",
      "enum": [
        "active",
        "inactive"
      ],
      "title": "Status",
      "type": "string"
    },
    "UIComponent": {
      "description": "The UI component available to the custom field",
      "enum": [
        "create",
        "details"
      ],
      "title": "UIComponent",
      "type": "string"
    }
  },
  "description": "A custom field for an entity in Albert.\n\nReturns\n-------\nCustomField\n    A CustomField that can be used to attach Metadata to an entity in Albert.\nAttributes\n------\nname : str\n    The name of the custom field. Cannot contain spaces.\nid : str | None\n    The Albert ID of the custom field.\nfield_type : FieldType\n    The type of the custom field. Allowed values are `list` and `string`. String fields cannot be searchable and are used to set uncontrolled metadata. List fields can be searchable and are used to set controlled metadata.\ndisplay_name : str\n    The display name of the custom field. Can contain spaces.\nsearchable : bool | None\n    Whether the custom field is searchable, optional. Defaults to False.\nservice : ServiceType\n    The service type the custom field is associated with.\nhidden : bool | None\n    Whether the custom field is hidden, optional. Defaults to False.\nlookup_column : bool | None\n    Whether the custom field is a lookup column, optional. Defaults to False. Only allowed for inventories.\nlookup_row : bool | None\n    Whether the custom field is a lookup row, optional. Defaults to False. Only allowed for formulas in inventories.\ncategory : FieldCategory | None\n    The category of the custom field, optional. Defaults to None. Required for list fields. Allowed values are `businessDefined` and `userDefined`.\nmin : int | None\n    The minimum value of the custom field, optional. Defaults to None.\nmax : int | None\n    The maximum value of the custom field, optional. Defaults to None.\nentity_categories : list[EntityCategory] | None\n    The entity categories of the custom field, optional. Defaults to None. Required for lookup row fields. Allowed values are `Formulas`, `RawMaterials`, `Consumables`, `Equipment`, `Property`, `Batch`, and `General`.\nui_components : list[UIComponent] | None\n    The UI components available to the custom field, optional. Defaults to None. Allowed values are `create` and `details`.",
  "properties": {
    "status": {
      "anyOf": [
        {
          "$ref": "#/$defs/Status"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "Created": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "Updated": {
      "anyOf": [
        {
          "$ref": "#/$defs/AuditFields"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "name": {
      "title": "Name",
      "type": "string"
    },
    "albertId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Albertid"
    },
    "type": {
      "$ref": "#/$defs/FieldType"
    },
    "labelName": {
      "default": null,
      "title": "Labelname",
      "type": "string"
    },
    "search": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Search"
    },
    "service": {
      "$ref": "#/$defs/ServiceType"
    },
    "hidden": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Hidden"
    },
    "lkpColumn": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Lkpcolumn"
    },
    "lkpRow": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Lkprow"
    },
    "category": {
      "anyOf": [
        {
          "$ref": "#/$defs/FieldCategory"
        },
        {
          "type": "null"
        }
      ],
      "default": null
    },
    "min": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Min"
    },
    "max": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Max"
    },
    "entityCategory": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/EntityCategory"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Entitycategory"
    },
    "ui_components": {
      "anyOf": [
        {
          "items": {
            "$ref": "#/$defs/UIComponent"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Ui Components"
    },
    "required": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Required"
    },
    "multiselect": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Multiselect"
    },
    "pattern": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Pattern"
    },
    "default": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "title": "Default"
    }
  },
  "required": [
    "name",
    "type",
    "service"
  ],
  "title": "CustomField",
  "type": "object"
}

Fields:

Validators:

name

name: str

id

id: str | None = None

field_type

field_type: FieldType

display_name

display_name: str = None

searchable

searchable: bool | None = None

service

service: ServiceType

hidden

hidden: bool | None = None

lookup_column

lookup_column: bool | None = None

lookup_row

lookup_row: bool | None = None

category

category: FieldCategory | None = None

min

min: int | None = None

max

max: int | None = None

entity_categories

entity_categories: list[EntityCategory] | None = None

ui_components

ui_components: list[UIComponent] | None = None

required

required: bool | None = None

multiselect

multiselect: bool | None = None

pattern

pattern: str | None = None

default

default: str | None = None

confirm_field_compatability

confirm_field_compatability() -> CustomField
Source code in src/albert/resources/custom_fields.py
@model_validator(mode="after")
def confirm_field_compatability(self) -> "CustomField":
    if self.field_type == FieldType.LIST and self.category is None:
        raise ValueError("Category must be set for list fields")
    return self