Skip to content

Commit aa96997

Browse files
andrewjschuanglcaresia
authored andcommitted
Add trigger workflow for each action (#14573)
* add trigger workflow for each action * bump version
1 parent df4ac64 commit aa96997

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import helperFunctions from "../../helper_functions.app.mjs";
2+
3+
export default {
4+
key: "helper_functions-trigger-workflow-for-each",
5+
name: "Trigger Workflow For Each",
6+
description: "Trigger another Pipedream workflow in your workspace for each object in an array.",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
helperFunctions,
11+
workflowId: {
12+
type: "string",
13+
label: "Workflow ID",
14+
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.",
15+
},
16+
objects: {
17+
type: "any",
18+
label: "Array of Objects",
19+
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.",
20+
},
21+
},
22+
async run({ $ }) {
23+
const {
24+
workflowId,
25+
objects,
26+
} = this;
27+
28+
try {
29+
const results = [];
30+
const triggerPromises = objects.map((object) => $.flow.trigger(workflowId, object));
31+
for await (const result of triggerPromises) {
32+
results.push(result);
33+
}
34+
$.export("$summary", `Successfully triggered workflow ID **${workflowId}**`);
35+
return results;
36+
} catch (error) {
37+
$.export("$summary", `Failed to trigger workflow ID **${workflowId}**.`);
38+
throw error;
39+
}
40+
},
41+
};

components/helper_functions/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/helper_functions",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"description": "Pipedream Helper_functions Components",
55
"main": "helper_functions.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)