docs: document when-then name
This commit is contained in:
@@ -599,7 +599,7 @@ export const subscriptionWorkflow1Highlights = [
|
||||
["16", "createWorkflow", "Create a workflow."],
|
||||
["23", "transform", "Set the customer ID to an empty string if not provided."],
|
||||
["28", "when", "If email is not set, try to retrieve customer by its ID."],
|
||||
["44", "transform", "Set the email either to the one in the input or the specified customer's email."],
|
||||
["48", "transform", "Set the email either to the one in the input or the specified customer's email."],
|
||||
]
|
||||
|
||||
```ts title="src/workflows/create-restock-subscription/index.ts" highlights={subscriptionWorkflow1Highlights}
|
||||
@@ -630,9 +630,13 @@ export const createRestockSubscriptionWorkflow = createWorkflow(
|
||||
}, (data) => {
|
||||
return data.customer.customer_id || ""
|
||||
})
|
||||
const retrievedCustomer = when({ customer }, ({ customer }) => {
|
||||
return !customer.email
|
||||
}).then(() => {
|
||||
const retrievedCustomer = when(
|
||||
"retrieve-customer-by-id",
|
||||
{ customer },
|
||||
({ customer }) => {
|
||||
return !customer.email
|
||||
}
|
||||
).then(() => {
|
||||
// @ts-ignore
|
||||
const { data } = useQueryGraphStep({
|
||||
entity: "customer",
|
||||
|
||||
@@ -1669,11 +1669,11 @@ export const createDpoWorkflowHighlights = [
|
||||
["27", "completeCartWorkflow", "Create an order for the cart."],
|
||||
["33", "useQueryGraphStep", "Retrieve the order's items and their associated variants and linked digital products."],
|
||||
["57", "when", "Check whether the order has any digital products."],
|
||||
["60", "then", "Perform the callback function if an order has digital products."],
|
||||
["63", "createDigitalProductOrderStep", "Create the digital product order."],
|
||||
["67", "createRemoteLinkStep", "Link the digital product order to the Medusa order."],
|
||||
["76", "createOrderFulfillmentWorkflow", "Create a fulfillment for the digital products in the order."],
|
||||
["90", "emitEventStep", "Emit the `digital_product_order.created` event."]
|
||||
["63", "then", "Perform the callback function if an order has digital products."],
|
||||
["66", "createDigitalProductOrderStep", "Create the digital product order."],
|
||||
["70", "createRemoteLinkStep", "Link the digital product order to the Medusa order."],
|
||||
["79", "createOrderFulfillmentWorkflow", "Create a fulfillment for the digital products in the order."],
|
||||
["93", "emitEventStep", "Emit the `digital_product_order.created` event."]
|
||||
]
|
||||
|
||||
```ts title="src/workflows/create-digital-product-order/index.ts" highlights={createDpoWorkflowHighlights} collapsibleLines="1-17" expandMoreLabel="Show Imports"
|
||||
@@ -1733,10 +1733,13 @@ const createDigitalProductOrderWorkflow = createWorkflow(
|
||||
}
|
||||
)
|
||||
|
||||
const digital_product_order = when(itemsWithDigitalProducts, (itemsWithDigitalProducts) => {
|
||||
return itemsWithDigitalProducts.length
|
||||
})
|
||||
.then(() => {
|
||||
const digital_product_order = when(
|
||||
"create-digital-product-order-condition",
|
||||
itemsWithDigitalProducts,
|
||||
(itemsWithDigitalProducts) => {
|
||||
return itemsWithDigitalProducts.length
|
||||
}
|
||||
).then(() => {
|
||||
const {
|
||||
digital_product_order,
|
||||
} = createDigitalProductOrderStep({
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
export const metadata = {
|
||||
title: `Workflow Errors`,
|
||||
}
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
## When-Then Error: Handler for action X Not Found
|
||||
|
||||
The following error may occur in production if you use a `when-then` block in your workflow:
|
||||
|
||||
```plain
|
||||
custom-workflow:when-then-01JE8Z0M1FXSE2NCK1G04S0RR2:invoke - Handler for action \"when-then-01JE8Z0M1FXSE2NCK1G04S0RR2\" not found...
|
||||
```
|
||||
|
||||
This occurs if the `when-then` block doesn't return a step's result and doesn't have a name specified. You can resolve it by passing a name as a first parameter of `when`:
|
||||
|
||||
```ts
|
||||
const result = when(
|
||||
"custom-when-condition",
|
||||
// ... rest of the parameters
|
||||
)
|
||||
```
|
||||
|
||||
Learn more about passing a name for `when-then` in [this documentation](!docs!/learn/fundamentals/workflows/conditions#specify-name-for-when-then)
|
||||
Reference in New Issue
Block a user