T
Twenty2mo ago
paulyili

Code Node (workflow)

I'm trying to set up a conditional logic using the Code Node, with the right condition i want the workflow to stop. I tried returning true / false but it continues the workflow. I also tried to throw an error, it would error on the right condition, but the next node will still fire. The workflow is something like Record is updated --> Code --> Create Company --> Create Person. The code is. export const main = async (params: { a: string; b: number; }): Promise<object> => { const { a, b } = params; if (a !== "APPROVED") { throw new Error("Not approved"); } return { status: "approved" }; }; for the Create Company and Person, the values are coming from the Record is Updated node as the code is not passing all the data. so when the Code node fails, it's still creating a Company and Person which it shouldn't.
2 Replies
martmull
martmull2mo ago
Hey, you did well to create a filter node using the code step. It is weird because when a node fails, exécution stops and children nodes are not supposed to be executed, Even if they use data from trigger node. Can you double check? It is a major issue if this is confirmed
paulyili
paulyiliOP2mo ago
100% this happens. i am on version 1.0 and i'm unsure if any changes to 1.1 . It should be easy to replicate. We just have another table for user registrations (website) and we get the first,last name, business name ph no, email and website to create a new company and person. we have a select field which we're using to trigger the workflow "Approved" which has Approved and Denied. to add, i've done over 100 tests and it always continues to create a new company and person when the code node fails. Another option was to pass all the data though the node code though B variable, but that started to get complex in getting the data to create the person and company. Maybe false alarm, in v 1.1.1 it seems to work. So will leave it at that. my flow now works as expected.

Did you find this page helpful?