Add Info to table
# 🤝help
s
So, I have a system that collects data from the user (name, email) but it different stages of the workflow. I have a table that has the following columns: first name, last name and email. When the bot collects a name, i have a find records that checks if that name is already inserted in the table. If it isn't, it adds a new row with the information and if it is, it just continues normally without adding anything. In other part of the workflow, the bot collects the user's email with the same system: checks if its already there, if it isn't it adds a new row if it is it just continues. The thing is, it adds a completely new row with just the user's email, but I want to update the row email with the input the bot has captured. I know I can do that with the update record card but I really don't know how to update the email record based on the user's name. For example: I want the update record to update the email for the user named Robert and just robert, not for any other row.
l
Ignore the Execute Card & Delete Record Card. In Execute I only have a console.log to check if I have got the correct record Use the Find Records to Find the particular Record and store that into an array variable and use the update card using the same variable to update the record referencing its id
c
Thank you @limited-pencil-78283 ! I've seen you in a few posts here and there 🙂 thanks so much for helping out the community!!!!
s
hey @limited-pencil-78283 @crooked-van-25152
just tried this and it doesn't work
it says null
l
Can you share screenshots?
s
sure
there it is @limited-pencil-78283
l
Please click on the + Add properties to update and add what you would like to get updated to the table. It should work
s
hasn't worked
It shows up an error
@limited-pencil-78283
any idea why?
l
can you put an execute card in between find and update and do a console.log(workflow.EmailDeUsuarioEncontrado[0])
and see if you get an output in the logs?
s
is that ok?
l
I don't see the output for console.log
s
where should it be?
l
check your personal messages, shared a link
checked and found that for some reason workflow and user level variables are showing undefined, even if they are defined @User @crooked-van-25152 - not sure whats wrong
b
I've had a similar issue before and they weren't getting defined because I had a syntax error. Could that be it?
l
It is two simple cards, one finds a record and stores value into an array variable, and then an update card which references the array[0].id and updates the email. There isn't any code written. Tried with both workflow and user variables same result. to verify added an execute card with two console.log statement, one just logs "Email is" and it is logged, the second one array[0] and the output is nothing
Also tried with a new variable to iron out the syntax errors, same result
b
Hello @swift-beach-91270 !!!, I am going to review it, however I am seeing that many search by name in the table and it should not be like that, remember that you can have several people in your table who will have the same name, this is a recommendation, use the email to search . I'm going to check your bot and see how I can help you.
s
hey boris
b
can you put it back? jaja
s
sorry but that bot i sent was a mistake
b
ok
s
it didn't show the same error
but it is basically what @limited-pencil-78283 said
I can share the bot again so you can fix the error it shows up but yeah
b
ok i will check
s
tyyy
let me know when you have any news
b
I'm on it 😉
l
here it is in node Standard1 -> Find Records -> change to first name is {{workflow.Nombredeusuario.first}} last name is {{workflow.Nombredeusuario.last}}
Also, the if logic is incorrect. If .lenght is 0 then it should route to node Standard4. and if .lenght is > 0 then it should update email
The issue was the code was searching for email address instead of the firstname and lastname and hence it always resulted in zero records
s
man
you saved me
really
in 2 hours I have a call with a possible client for a real estate bot and this was the only thing missing
thank you so much man
l
you are most welcome...
s
I just have to connect that table to a google sheet with make and that's it
but I have a question, why was the logic in the ifs wrong?
because when capturing the name and adding it to the table, I used the same logic and it worked
if find records didn't find any name like that, it would add it, since the length of the find record's variable would be 0
l
after changing the search, we have to find the record that matches the first and last name and if it found the record, you wanted to update email, so .lenght > 0
Again, use the correct logic you need. I tried to update email, when I found the first and last name else skip it
Also ponder on the input from @billowy-morning-42410 you could possible have many names the same
s
yeah that's right
but for now it works
thanks a lot man
b
Yes, I am making some improvements and considerations, I will give you the bot in a moment
s
Hey and does anyone know how to connect the table to google sheets with make??
Can't find any tutorials
b
s
thanks man, it'll help a lot
.
b
Prepare an example where I think your approach should be. First you must do the search by email, then know how to use the arrangement of objects that it provides and that is what @limited-pencil-78283 told you to do. Please try the example and take advantage of it. There are many things we can adjust but I don't know your use case.
You should do the insertion process all at once, not step by step, it is not recommended. I mean that the forms receive all the data and at the end when the user makes sure it then goes to the database. What I recommend is that you do not ask for a value and insert and then ask for another and insert again, you must accumulate the values ​​in variables and at the end send them to the database. I could have done the process as you had but it is a mistake.
This with respect to the process of first time you insert. When you want to update a value already inserted you must keep in mind that findRecors brings an array of objects and that is why it is important that the search is for a key field such as email, since we know in a field that it is not repeated from user to user, It's unique. So you know that the search will only bring you an array with an object in position 0 or it will bring an empty array. If you continue doing it by name, one day it will bring you 2 or 3 objects that have the same name and there you would have to manage it, ok, be careful with that.
😉
m
Did you get this sorted?
2 Views