-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add trigger workflow for each action (#14573)
* add trigger workflow for each action * bump version
- Loading branch information
1 parent
df4ac64
commit aa96997
Showing
2 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
components/helper_functions/actions/trigger-workflow-for-each/trigger-workflow-for-each.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import helperFunctions from "../../helper_functions.app.mjs"; | ||
|
||
export default { | ||
key: "helper_functions-trigger-workflow-for-each", | ||
name: "Trigger Workflow For Each", | ||
description: "Trigger another Pipedream workflow in your workspace for each object in an array.", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
helperFunctions, | ||
workflowId: { | ||
type: "string", | ||
label: "Workflow ID", | ||
description: "The ID of the workflow to trigger. Workflow IDs are formatted as `p_******` and you can find a workflow's ID within the workflow builder URL.", | ||
}, | ||
objects: { | ||
type: "any", | ||
label: "Array of Objects", | ||
description: "Use a custom expression (`{{steps.code.objects}}`) to reference an array of objects exported from a previous step to send to the triggered workflow.", | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const { | ||
workflowId, | ||
objects, | ||
} = this; | ||
|
||
try { | ||
const results = []; | ||
const triggerPromises = objects.map((object) => $.flow.trigger(workflowId, object)); | ||
for await (const result of triggerPromises) { | ||
results.push(result); | ||
} | ||
$.export("$summary", `Successfully triggered workflow ID **${workflowId}**`); | ||
return results; | ||
} catch (error) { | ||
$.export("$summary", `Failed to trigger workflow ID **${workflowId}**.`); | ||
throw error; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters