Send Email template to a List of Customers if status of them is registered

Hi Everyone,

I am creating an automated Email system for a shipping Company.

I have no knowledge of programming but I want to send an email every time I “create a new Load” on my “Load Board” custom module I did with Module Builder. The Information of the new Load I created have to be sent after saved to a list of Curriers I have on a “Curriers” Module I created with Module Builder. The Email have to be sent only if the status field of the Currier is “registered”. My SuiteCRM is 7.9.7.

I read I need to create a Logic Hooks for that, so I am searching the Code to make it works. I found I need to create two files: “logic_hooks.php” and “send _email.php” and put it on modules/te_lb_load_board folder.

As I understand the system has to take the emails list from database mysql, check if the staus is “registered”, take the custom email template I created with the “Email Template” module and send it with SugarPHPMailer.php

Can someone please tell me if I am right?

I think you can do that with an “on save” Workflow, and it won’t require any code.

hi pgr,

thank you for your answer. Do you mean something like this?

Whatever works for you :slight_smile:

Just try it. I don’t really know that much about Workflows.

I don’t see why you would have all those conditions. If it’s to supposed to send for every new record, then you shouldn’t add any restrictions there.

I don’t know how to map the fields on to the Email, though (I suppose that’s what you were trying to achieve). Try searching online for examples of email-sending workflows.

There is some documentation about the “Send mail” action here:
https://suitecrm.com/wiki/index.php/Userguide#Actions

Good luck

Hi pgr,

Thank you very much for your Information.

It starts sending Emails but I have this problem: I receive the Email Template when I create a new Currier and not when I create a new Load.
The second problem is that the email template is without information.

Maybe it is a problem of relationship between the “Load Board” Module and the “Curriers” Module?

Here the photos how I set up it:

Hi there,

Does someone have an Idea how to set up the relationships in this case? I think this could help others too. I would really appreciate any suggestion.

I am a bit lost, but Ijust had an idea.

Try solving one problem at a time. Try a Workflow with a simple, out-of-the-box module, like Contacts. Try to get some Contact variables showing in the Template. If that succeeds, then go to a simple custom module. Then one that needs to cross a relationship.

Also, are you sure you want to run this workflow only for “New records”? Not “modified records”? If somebody changes that field to “registered”, on an existing record, don’t you want the email sent out?

hi,

I am not sure but I think if a User change the status of a Currier to “registered” and then a User create a new Load, the new registered Currier should receive the new Load Opportunity per Email.

As I am not so far I have at the moment another Problem. I made a Test: I set the Workflow to send an Email to my email Address and it worked. I received an Email with the Template “Load Opportunity” I did and with the Information of the new Load created.

Now, I have to set the relationship between the Module “Load Board” and the Module “Currier”. I tested some relationships but I am still not finding the right one.
I created a relationship like this on the Photo below but I can not find the Field “email address” on the “Edit View” in the “Curriers” Module.

Does someone have suggestions how I can send Emails to the Curriers? I am a step from resolving this problem I think. I am trying all different combinations without success.

Does someone have any suggestion? It seems impossible to send mass emails through workflow… . Can someone please tell me if it has to be done with a logic hooks or if it can be done with a workflow?

What is (in business terms) the relationship between Load and Currier?

I am wondering if you could have an intermediate step:

  • use a workflow to copy the email address from one to the other, whenever it changes

  • now you could have the email address easily accessible so that your workflow is easier to make

I don’t know if this makes sense, I am just suggesting an alternative approach that might work.

The Business Term is this:

The Curriers who have a truck need a Load for their Business. The Company search a Load and add the Load into the Module “Load Board”. After the Load is saved the Currier receive automatically the Load Opportunity per Email.

I thought about your suggestion. You mean I can create a Workflow to add all Currier’s Emails into the “Load Board” Module so I will be able to send them the Emails from another Workflow?

You mean with this method I can grab all the Currier’s Emails? (Curriers could be 1000)

I read some Posts and I figure out I need to create a custom Action to send Email to all Curriers. I am trying to understand how to modify the “actionSendEMail.php”.

If someone can please write me some suggestions I would really appreciate that as I have zero Knowledge about programming and I am learning just by doing. Thanks

(a previous question, just a matter of the English language: you probably mean “Couriers”, since “Curriers” are people who deal in leather)

I don’t mean to move 1000 email addresses into the other record; I was just thinking if you could move ONE address, the correct one, so that you have it readily available when you need it in the Workflow.

If, for example, when you create the record “Load Board”, you already know which Courier it is, you add that email there. (But maybe I’m still not interpreting your situation correctly.)

About the logic hook or the custom action: you don’t really mean you know “zero” about programming, do you? If so, then it is impossible to help you: these are programming tasks, and it is beyond he scope of this forum to educate you in that. Or do you mean that you can do some bits of programming?

1 Like