Send emails depending on a value of the record

Hello there!

Id developing a ticketing platform. I have set an add view to send a mail to my support email address when a user creates a new ticket,which is always the same.

Then, if the user adds a message, the view send a mail to my support email address, which is always the same too.

But, if me, as an admin, I add a new message, I need to search what email does the user has in their account to send the email to the user like “hey you goy a new response for the ticket XXX from an operator or admin”.

Is there any posibilities i can make the $rec_email has a sql value like: SELECT email FROM users WHERE user_id=the_id_of_the_person_who_created_the_ticket ?

Please help with this :slight_smile:

Use the Action After Add configuration in Page Events, to query the email from your database and send the mail to the user. There are snippets on the right panel for queries and also to send emails, you just have to double click to get the snippet.

OK, solved, thank you :slight_smile:
Now another question…

It is a ticket system, so there are users who report tickets, a ticket table where information is stored about the tickets that users register along with the ID of the user who has registered that ticket, and a table of messages from tickets, where discussions are added to user tickets and operator responses in which is the ID of the ticket to which that response belongs, so that subqueries can be made like:
From the ticket_messages table I have to be able to get the email of the user who has reported the ticket to which I am adding the message.

TABLE DIAGRAM:

Thank you for your help

You either write a query using JOIN to links the tables or you query each table using the result from each query to make the quesry for the next table. use the ticket_id to get ticket details, then use the user_id form ticket table to get the user details.

That is correct, thank you.
I’ve tried adding the query on page events as you said, but, email doesn’t send. I think is for sintax on the php statement:

what do you think?

Make sure you have configured mail settings in Project Settings. If you still, do a dd() of value and share the log.

dd($value);

How do i do that? Where do i insert that and enable loggin or where do i find the log? i’m new into radsys…

dd($value);

Add it inside your code and trying adding a record to see what it displace, share what it displays. Hide all personal info from the log you share here.