docs: document when-then name

This commit is contained in:
Shahed Nasser committed 2024-12-11 11:00:25 +02:00
1 parent fad85a9d29
commit fd23f13cfd
10 files changed
+2082 -4880

No files matched your search

@@ -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)
+3 -2
View File
@@ -126,7 +126,7 @@ export const generatedEditDates = {
"app/nextjs-starter/page.mdx": "2024-12-10T08:44:33.783Z",
"app/recipes/b2b/page.mdx": "2024-10-03T13:07:44.153Z",
"app/recipes/commerce-automation/page.mdx": "2024-10-16T08:52:01.585Z",
"app/recipes/digital-products/examples/standard/page.mdx": "2024-12-09T16:18:45.973Z",
"app/recipes/digital-products/examples/standard/page.mdx": "2024-12-11T08:46:17.435Z",
"app/recipes/digital-products/page.mdx": "2024-10-03T13:07:44.147Z",
"app/recipes/ecommerce/page.mdx": "2024-10-22T11:01:01.218Z",
"app/recipes/integrate-ecommerce-stack/page.mdx": "2024-12-09T13:03:35.846Z",
@@ -5687,5 +5687,6 @@ export const generatedEditDates = {
"references/modules/sales_channel_models/page.mdx": "2024-12-10T14:55:13.205Z",
"references/types/DmlTypes/types/types.DmlTypes.KnownDataTypes/page.mdx": "2024-12-10T14:54:55.434Z",
"references/types/DmlTypes/types/types.DmlTypes.RelationshipTypes/page.mdx": "2024-12-10T14:54:55.435Z",
"app/recipes/commerce-automation/restock-notification/page.mdx": "2024-12-10T14:15:39.178Z"
"app/recipes/commerce-automation/restock-notification/page.mdx": "2024-12-11T08:47:27.471Z",
"app/troubleshooting/workflow-errors/page.mdx": "2024-12-11T08:44:36.598Z"
}
File diff suppressed because it is too large. Load diff
+8
View File
@@ -9309,6 +9309,14 @@ export const generatedSidebar = [
"path": "/troubleshooting/dist-imports",
"title": "Importing from /dist",
"children": []
},
{
"loaded": true,
"isPathHref": true,
"type": "link",
"path": "/troubleshooting/workflow-errors",
"title": "Workflow Errors",
"children": []
}
]
},
+5
View File
@@ -2249,6 +2249,11 @@ export const sidebar = sidebarAttachHrefCommonOptions([
path: "/troubleshooting/dist-imports",
title: "Importing from /dist",
},
{
type: "link",
path: "/troubleshooting/workflow-errors",
title: "Workflow Errors",
},
],
},
{