Property definitions: discover the fields an object type has (including custom properties and enumeration options) and create new ones.

Functions

archive-property

fn (object-type: Str, name: Str): Any
fn (object-type: Str, name: Str, opts: Map): Any

DELETE /crm/properties/{version}/{objectType}/{propertyName} - Archive a custom property (HubSpot default properties cannot be archived).

Example

::hubspot::properties/archive-property("contacts", "favorite_product")

build-property-body

fn (definition: Map): Map

Validate and build a create-property payload. Required: name (internal, lowercase), label, type (string, number, date, datetime, enumeration, bool, phone_number), fieldType (text, textarea, number, date, select, radio, checkbox, booleancheckbox, phonenumber, file, html, calculation_equation), and groupName (e.g. "contactinformation"). Optional: description, options (Vec of {label, value, displayOrder, hidden} for enumerations), hasUniqueValue, hidden, formField, displayOrder. Unset keys are omitted. Exposed for testing.

Example

::hubspot::properties/build-property-body({name: "tier", label: "Tier", type: "string", fieldType: "text", groupName: "contactinformation", hidden: null})
// {name: "tier", label: "Tier", type: "string", fieldType: "text", groupName: "contactinformation"}

is-err(::hubspot::properties/build-property-body({name: "tier"}))  // true

create-property

fn (object-type: Str, definition: Map): Map
fn (object-type: Str, definition: Map, opts: Map): Map

POST /crm/properties/{version}/{objectType} - Create a custom property. See build-property-body for the fields.

Example

::hubspot::properties/create-property("contacts", {
  name: "favorite_product",
  label: "Favorite product",
  type: "enumeration",
  fieldType: "select",
  groupName: "contactinformation",
  options: [
    {label: "Widgets", value: "widgets", displayOrder: 0, hidden: false},
    {label: "Gadgets", value: "gadgets", displayOrder: 1, hidden: false}
  ]
})

get-property

fn (object-type: Str, name: Str): Map
fn (object-type: Str, name: Str, opts: Map): Map

GET /crm/properties/{version}/{objectType}/{propertyName} - One property definition, including options for enumeration properties (the valid values to write).

Example

prop ::hubspot::properties/get-property("deals", "dealstage")
map(prop.options, %.value)

list-properties

fn (object-type: Str): Map
fn (object-type: Str, params: Map): Map
fn (object-type: Str, params: Map, opts: Map): Map

GET /crm/properties/{version}/{objectType} - Every property definition for an object type: {results: [{name, label, type, fieldType, groupName, options, hasUniqueValue, calculated, ...}]}. params: archived, properties (Vec of names to return), locale.

Example

out ::hubspot::properties/list-properties("contacts")
map(out.results, %.name)

update-property

fn (object-type: Str, name: Str, changes: Map): Map
fn (object-type: Str, name: Str, changes: Map, opts: Map): Map

PATCH /crm/properties/{version}/{objectType}/{propertyName} - Change a property's label, description, options, groupName, hidden, and similar fields.

Example

::hubspot::properties/update-property("contacts", "favorite_product", {label: "Top product"})