← Workflow Academy

Workflow Academy · 4 / 5

Carry the ready result into Lua

Add a reusable source file that returns a receipt for ready jobs.

YOUR TASK

Make this happen

3 steps
  1. Add a receipt script node after ready and load scripts/receipt.lua. Read envelope.ready.jobId and envelope.ready.status from the predecessor envelope.

  2. Keep the working capabilities from the previous lesson and connect the new pieces to the same solution.

  3. Check the complete solution, then inspect any unmet requirements.

This step starts with the earlier solution and one new challenge. Each lesson keeps its own draft.

Read the starter files

main.cococo

workflow_document "main" {
  nodes = [workflow_node.prepare, workflow_node.route, workflow_node.review, workflow_node.ready]
  edges = [workflow_edge.prepare_route, workflow_edge.review, workflow_edge.ready]
  inputSchema = {
    type = "object"
    properties = {
      jobId = {
        type = "string"
      }
      copies = {
        type = "integer"
        minimum = 1
      }
    }
    required = ["jobId", "copies"]
  }
}

prepare.cococo

workflow_node "prepare" {
  id = "prepare"
  type = "transform"
  config = {
    mapping = {
      copies = "{{ input.copies }}"
      jobId = "{{ input.jobId }}"
    }
  }
}

route.cococo

workflow_node "route" {
  id = "route"
  type = "condition"
  config = {
    expression = "nodes.prepare.output.copies > 100"
  }
}

review.cococo

workflow_node "review" {
  id = "review"
  type = "transform"
  config = {
    mapping = {
      status = "review"
      jobId = "{{ nodes.prepare.output.jobId }}"
    }
  }
}

ready.cococo

workflow_node "ready" {
  id = "ready"
  type = "transform"
  config = {
    mapping = {
      status = "ready"
      jobId = "{{ nodes.prepare.output.jobId }}"
    }
  }
}

links.cococo

workflow_edge "prepare_route" {
  from = "prepare"
  to = "route"
}
workflow_edge "review" {
  from = "route"
  to = "review"
  when = "true"
}
workflow_edge "ready" {
  from = "route"
  to = "ready"
  when = "false"
}

receipt.cococo

workflow_node "receipt" {
  id = "receipt"
  type = "script"
  config = {
    # TODO: add the mapping/expression or script input described above.
  }
}

scripts/receipt.lua

local envelope = ...
-- TODO: build a receipt from the predecessor output described in the task.
return {}
Supplied supporting files

Reference: workflows · introductionworkflows · getting-startedworkflows · valuesworkflows · branchesworkflows · scriptsworkflows · node-formsworkflows · publicationworkflows · diagnosticsworkflows · referenceworkflows · node-reference