Pipelines and their stages for deals, tickets, and other
pipeline-backed objects. Deal and ticket dealstage/hs_pipeline_stage
values are stage ids ("appointmentscheduled", or numeric ids in
custom pipelines), not the labels users see, so resolve labels here
before writing them.
Functions
find-stage
fn (object-type: Str, pipeline: Str, stage: Str): Any
fn (object-type: Str, pipeline: Str, stage: Str, opts: Map): Any
Look up a stage by pipeline and stage id or label, e.g.
find-stage("deals", "Sales Pipeline", "Contract Sent"). Returns
{pipeline_id, stage_id, stage} or null.
Example
found ::hubspot::pipelines/find-stage("deals", "default", "Contract Sent")
if(is-some(found),
::hubspot::deals/update-deal("12345", {pipeline: found.pipeline_id, dealstage: found.stage_id}),
null)
find-stage-in
fn (pipelines: Map, pipeline: Str, stage: Str): Map?
Resolve a stage from a list-pipelines response. pipeline and
stage each match an id or a label (case-insensitive). Returns
{pipeline_id, stage_id, stage} or null. Exposed for testing;
find-stage calls the API.
get-pipeline
fn (object-type: Str, pipeline-id: Str): Map
fn (object-type: Str, pipeline-id: Str, opts: Map): Map
GET /crm/pipelines/{version}/{objectType}/{pipelineId} - One pipeline with its stages. The default deal pipeline's id is "default".
get-stage
fn (object-type: Str, pipeline-id: Str, stage-id: Str): Map
fn (object-type: Str, pipeline-id: Str, stage-id: Str, opts: Map): Map
GET /crm/pipelines/{version}/{objectType}/{pipelineId}/stages/{stageId} - One stage.
list-pipelines
fn (object-type: Str): Map
fn (object-type: Str, opts: Map): Map
GET /crm/pipelines/{version}/{objectType} - Every pipeline for an
object type ("deals", "tickets", ...) with its stages: {results: [{id, label, displayOrder, stages: [{id, label, displayOrder, metadata}]}]}. Deal stage metadata.probability is the win
probability; metadata.isClosed marks closed stages.
list-stages
fn (object-type: Str, pipeline-id: Str): Map
fn (object-type: Str, pipeline-id: Str, opts: Map): Map
GET /crm/pipelines/{version}/{objectType}/{pipelineId}/stages - The stages of one pipeline: {results: [{id, label, displayOrder, metadata}]}.
matches
fn (item: Map, wanted: Str): Bool