Preciso de um Java Script para filtra uma informação em uma tabela

In the Workflow below I would like a java Script that returns the Whatsapp field that contains the DDD equal to SET1


table image

Excuse my ignorance, I’m studying Java Script, but I still can’t create this code, could someone help me?

Hey @admdiegolima,

Does it need to be javascript? It sounds like you could probably do the same thing with an If node although I don’t know what the DDD actually is to work out what it relates to. Is it the prefix / dialing code (11)?

If this is the case I would do something like the below, Set the DDD value before getting your data then after you have the data you can use an If node to see if the number starts with the DDD. In this example the Code node (Mock Data) just generates some random data that is similar to what you have in your table.

This the DDD is the prefix/code, here in Brazil each state has a prefix, where São Paulo is (11), Rio de Janeiro is (21), Brasília (61)

so what I want to do is the following, I first make a get many call, pulling a table that contains the data as below:

11 - live in São Paulo
21 - Live in Rio de Janeiro
61 - Live in Brasilia

and so on this table returns approximately 70 rows.

then in another bubble node I look for customer records where the phone number returns.

let’s say we create a customer named Charles and his phone number is (61) 9 8890-8787

I want to search in the first node of the bubble which line contains “61” and then in a fourth node I do an update recording in a field “prefix/code”

I was doing this to call attention to getmany from the prefix table every time I ran the loop, but I was using the bubble data api and it gave an error, so I want to search the memory of the n8n with a java script, can you help me ?

Hey @admdiegolima,

You should be able to follow what I did above to achieve that, but rather than an If node you could use a switch node and if the number doesn’t start with (xx) pass it to an output so it would be something like the below.

This can also be taken 1 step further if needed and you could have both 11 and (11) direct through the switch node as well then apply your action.

With 70 random items the output looks like this…

can’t you do it dynamically through the code node, with a java script?

because that way I will need to follow 70 paths with the switch node

Hey @admdiegolima,

Ah ok 70 different dialling codes is tricky, This could be done with a code node if you were willing to spend some time with javascript but it would depend on what you need to output to look like so you can use it in the next node.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.