update when-then blocks across docs
This commit is contained in:
@@ -541,12 +541,14 @@ In the workflow, you retrieve the customer's linked `Custom` record using Query.
|
||||
Next, replace the `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts"
|
||||
const created = when({
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
!data.customers[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
const created = when(
|
||||
"create-customer-custom-link"
|
||||
{
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
!data.customers[0].custom &&
|
||||
data.input.additional_data?.custom_name?.length > 0
|
||||
)
|
||||
.then(() => {
|
||||
const custom = createCustomStep({
|
||||
@@ -575,14 +577,16 @@ To create the `Custom` record, you use the `createCustomStep` you created in an
|
||||
Next, replace the new `TODO` with the following:
|
||||
|
||||
```ts title="src/workflows/update-custom-from-customer/index.ts"
|
||||
const deleted = when({
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
data.customers[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
const deleted = when(
|
||||
"delete-customer-custom-link",
|
||||
{
|
||||
input,
|
||||
customers,
|
||||
}, (data) =>
|
||||
data.customers[0].custom && (
|
||||
data.input.additional_data?.custom_name === null ||
|
||||
data.input.additional_data?.custom_name.length === 0
|
||||
)
|
||||
)
|
||||
.then(() => {
|
||||
deleteCustomStep({
|
||||
@@ -611,12 +615,10 @@ const updated = when({
|
||||
customers,
|
||||
}, (data) => data.customers[0].custom && data.input.additional_data?.custom_name?.length > 0)
|
||||
.then(() => {
|
||||
const custom = updateCustomStep({
|
||||
return updateCustomStep({
|
||||
id: customers[0].custom.id,
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
return custom
|
||||
})
|
||||
|
||||
return new WorkflowResponse({
|
||||
|
||||
Reference in New Issue
Block a user