Skip to content

Commit

Permalink
Merge pull request Budibase#14507 from Budibase/BUDI-8609/run-row-act…
Browse files Browse the repository at this point in the history
…ion-as-sync

Run row action as sync
  • Loading branch information
adrinr authored Sep 3, 2024
2 parents daf8909 + b74efe5 commit d54f87a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
12 changes: 10 additions & 2 deletions packages/server/src/api/routes/tests/rowAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ describe("/rowsActions", () => {
}

it("can trigger an automation given valid data", async () => {
expect(await getAutomationLogs()).toBeEmpty()
await config.api.rowAction.trigger(tableId, rowAction.id, {
rowId: row._id!,
})
Expand All @@ -680,13 +681,19 @@ describe("/rowsActions", () => {
expect(automationLogs).toEqual([
expect.objectContaining({
automationId: rowAction.automationId,
trigger: expect.objectContaining({
trigger: {
id: "trigger",
stepId: "ROW_ACTION",
inputs: null,
outputs: {
fields: {},
row: await config.api.row.get(tableId, row._id!),
table: await config.api.table.get(tableId),
automation: expect.objectContaining({
_id: rowAction.automationId,
}),
},
}),
},
}),
])
})
Expand Down Expand Up @@ -731,6 +738,7 @@ describe("/rowsActions", () => {
)

await config.publish()
expect(await getAutomationLogs()).toBeEmpty()
await config.api.rowAction.trigger(viewId, rowAction.id, {
rowId: row._id!,
})
Expand Down
16 changes: 10 additions & 6 deletions packages/server/src/sdk/app/rowActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,15 @@ export async function run(tableId: any, rowActionId: any, rowId: string) {
const automation = await sdk.automations.get(rowAction.automationId)

const row = await sdk.rows.find(tableId, rowId)
await triggers.externalTrigger(automation, {
fields: {
row,
table,
await triggers.externalTrigger(
automation,
{
fields: {
row,
table,
},
appId: context.getAppId(),
},
appId: context.getAppId(),
})
{ getResponses: true }
)
}

0 comments on commit d54f87a

Please sign in to comment.