Solved: Sending an email when saving a form

ahmedo

Member
If I can achieve this with your support, it will make me a proud old man. Here we go.

I am trying to create a simple sales lead system.

Our sales support personal adds a new record. In that record, there is a field called assign_to (databasejoin). This field shows a droplist of the salespeople in our company. Once the sales support personal saves the form, I want an email to be sent to the salesperson to inform him/her that there is a new lead for him/her to follow, and to the sales manager too who is not part of the recrod. I also want a link to that record included in that email.

I may be asking for too much here. But it is one of the main reason I am using Fabrik and posting here.

(there goes my weekend).
 
Yup, this is 'built in'.
In your form add an email plugin (On=new if you only want to send if it's a new record).

Email "To":
depends on your elements and setup. If your dbjoin is showing the email you can use the placeholder
{your-dropdown-element}
If the dbjoin elements is e.g. value=id, label=name
you have to use the "email to (eval)" to fetch the email address.

Same with the sales manager: if this is the (logged-in) person who is creating the record his email address (from the Joomla user account) is in
{$my->email}
If it's some other relation you have to fetch it via PHP in "email to (eval)".

Link to the record:
In the "Message Text" include something like (copy/paste the record URL, replace the record id with the placeholder of your id element)

<a href="https://your-site/.../form/13/{table___id_raw}">LINK</a>
 
Actually there are four built in placeholders you can use in message content for links ...

{fabrik_viewurl} - URL to the details view
{fabrik_editurl} - URL to the edit view
{fabrik_viewlink} - clickable link to the details view (using the language string for 'COM_FABRIK_VIEW', usually "View")
{fabrik_editink} - clickable link to the form view (using the language string for 'COM_FABRIK_EDIT', usually "Edit")

So you can either us {fabrik_editlink} by itself if you don't mind "Edit" being the visible link text, or ...

Code:
<a href="{fabrik_editurl}">Your text Here</a>

-- hugh
 
Last edited:
Thank you both for your reply. This was beyond my pay scale. So I had to call our in-house PHP expert. After some fiddling based on your feedback and some googling, he figured out what needs to be done. I will post the step by step instruction as it may be useful to others who have similar needs.

He did ask me a question, and and I could not answer. He wanted to know if it is possible to declare a variable in PHP in the Email to (eval) and parse it in the Message Text window or box for it to appear in the email sent? We have tried different methods to no avail.

Thank you once again.
 
He did ask me a question, and and I could not answer. He wanted to know if it is possible to declare a variable in PHP in the Email to (eval) and parse it in the Message Text window or box for it to appear in the email sent? We have tried different methods to no avail.

What are you trying to do? I'm guessing you want to grab some other data from the staff table to include in the mail.

The answer is probably yes. You could add something to $this->data, which is the form data array that gets used for replacing placeholders. So ...

Code:
// blah blah ... some code that reads a sales table row from the database into the $row object ...
$this->data['salesperson_jobtitle'] = $row->jobtitle;

... and you should then be able to use {salesperson_jobtitle} in your message template.

Just be VERY careful not to stomp on any existing data in there. Use a naming convention for the array key (/ placeholder name) that is guarranteed to be unique.

-- hugh
 
What are you trying to do? I'm guessing you want to grab some other data from the staff table to include in the mail.

This we could do eventually. I was happy about it. Needless to say, the more we knew the more wanted to do more.

I think he just wants to be able to declare his own variable for some reasons and then as part of the email.
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top