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.
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.