Code Examples for Workflows
Are there any code examples that anyone has shared for the Code Workflow action? Specifically I'm curious how I should go about accessing the GraphQL API from a Code action. I'm very familiar with GraphQL from having worked a lot with Shopify, but I'm not so familiar with how to use it in this environment. For instance, should I just hardcode my API key into the code?
Side note: I can access quite a few useful variables via
process.env, even though shows an error in the code editor.27 Replies
@Baptiste Devessier could you take a look please?
Hi, there are no code examples for now AFAIK. You will have to hardcode your API key into the code indeed
Just to understand the code block, it's independent of the previous block ?
I wanted to fetch records using the "search records", and then apply a small function on the array. There is no way of doing that ?
It can be but it's not a requirement, if you want to use the output of previous block, you have to pass it to a function as an argument like here, just make sure you match the type of argument

But the best way would be to just use iterator to iterate over all records and pass current object to code node
Ahh perfect, it's working ! But now I cannot use the output of the code block for the next block :

My goal is to get all tasks that are late (dueDate before today), and send an e-mail with the list of the tasks (title)
I use that as a function, and it's working when I click "test" :
@TimM process.env may contain information about the AWS Lambda environment. What useful variables can we get from it?
Return it as an object like
return { output: message };
From what I remember, all functions work only on objects so passing a "simple" type like number or string won't workI managed to make the test function work. The issue is that the input for the test function is a string, and the code block is using an object.
So I did a little conversion :
But now, the output of message, or output in the next block is :
instead of just the text
You need to click on "Generate Function Output"
Yes I have this now

But the mail I receive is :
It will make you run the function in the test tab, and next steps will be able to infer return type by infering the test result
it would be nice to be able to have the same input in the test tab as in the code tab. Because in "code" we can an Array, but in "test" it's always a string
I read
export const main = async (params: {
tasks: string | Task[]; // can be a JSON string or an array
totalCount?: number; // optional; defaults to tasks.length
})
Why tasks is string or task[] ?
to handle the test tab
ok thats indeed an issue, let me check
ok ok indeed
@thomast when do we plan to have properly typed inputs in workflow steps?
and any idea why the output is a full object instead of just my serverless output string ?
Ineed there is an issue with body formatting, email step receives the proper input but email body is wrong


@hilarex you have spotted an issue thanks, we will fix that
@thomast looks like the body content in send email step is wrong wdyt?

glad I could help !
@Félix does it ring a bell ?
the recent refacto of the body input may be the root cause https://github.com/twentyhq/twenty/pull/15157. Did not investigate deeper though
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
Hello, any update on this issue ? I'm on version v1.11.5