diff --git a/server/src/services/pipelines.test.ts b/server/src/services/pipelines.test.ts index 81a5624ccd6..f94382cd681 100644 --- a/server/src/services/pipelines.test.ts +++ b/server/src/services/pipelines.test.ts @@ -8,8 +8,9 @@ describe("pipeline service helpers", () => { pipelineId: "pipeline-1", config: { variables: [ - { key: "customer", label: "Customer", type: "text", required: true, options: [], showInAddForm: false }, - { key: "urgency", label: "Urgency", type: "select", options: ["low", "high"], required: false, showInAddForm: false }, + { key: "customer", label: "Customer", type: "text", required: true, options: [], showInAddForm: true }, + { key: "urgency", label: "Urgency", type: "select", options: ["low", "high"], required: false, showInAddForm: true }, + { key: "internal_notes", label: "Internal notes", type: "multiline", required: true, options: [], showInAddForm: false }, ], }, }, @@ -49,8 +50,9 @@ describe("pipeline service helpers", () => { it("validates required intake fields for pipeline stage variables", () => { const variables = [ - { key: "customer", label: "Customer", type: "text" as const, required: true, options: [], showInAddForm: false }, - { key: "notes", label: "Notes", type: "multiline" as const, required: false, options: [], showInAddForm: false }, + { key: "customer", label: "Customer", type: "text" as const, required: true, options: [], showInAddForm: true }, + { key: "notes", label: "Notes", type: "multiline" as const, required: false, options: [], showInAddForm: true }, + { key: "internal_code", label: "Internal code", type: "text" as const, required: true, options: [], showInAddForm: false }, ]; expect(() => validateStageRequiredFields({ customer: "Acme" }, variables), diff --git a/server/src/services/pipelines.ts b/server/src/services/pipelines.ts index 3f8800b9098..07e030959c7 100644 --- a/server/src/services/pipelines.ts +++ b/server/src/services/pipelines.ts @@ -101,13 +101,15 @@ export function extractPipelineIntakeFormFields(stages: PipelineStageRow[]): Pip const first = stages[0]; if (!first) return []; const stageConfig = normalizeStageConfig(first.config); - return stageConfig.variables.map((variable) => ({ - key: variable.key, - label: variable.label, - type: variable.type, - required: variable.required, - options: variable.options, - })); + return stageConfig.variables + .filter((variable) => variable.showInAddForm) + .map((variable) => ({ + key: variable.key, + label: variable.label, + type: variable.type, + required: variable.required, + options: variable.options, + })); } export function validateStageRequiredFields( @@ -115,6 +117,7 @@ export function validateStageRequiredFields( stageVariables: PipelineStageVariable[], ) { const missing = stageVariables + .filter((variable) => variable.showInAddForm) .filter((variable) => variable.required) .filter((variable) => { const value = fields[variable.key]; @@ -246,7 +249,9 @@ async function resolvePipelineIntakeStage(db: PipelineDb, pipelineId: string, st function validateStageRequiredFieldsForIngest(stage: PipelineStageRow, fields: Record) { const config = normalizeStageConfig(stage.config); - const requiredVariables = Array.isArray(config.variables) ? config.variables : []; + const requiredVariables = Array.isArray(config.variables) + ? config.variables.filter((variable) => variable.showInAddForm) + : []; validateStageRequiredFields(fields, requiredVariables); }