How to add Custom Field in Workflow

Hi There,

I’ve made a custom field in Contacts name Cellphone notification. This field contains Email to text email (For example 1234567890@tmomail.net)

Now I want to create a workflow. Any case which has “created by contact” field populated by contact name. The system should send email notification of case update to my custom field which is Email to Text filed.

Please help me solve this one.

Thank You

Don’t use a text field for that, otherwise the system won’t know how to email it.

Contacts already have a mechanism to use more than one email. You can have a list of emails attached to a Contact. Try working with that, without any custom fields. You can try knowing which email is the email-to-text one by checking the domain (tmomail.net)

Hi,

You are right Contacts is able to handle more than one email. When I add more than one email (in my case one text to email, and one email). Notification is only sent to either one of them.

If I select any email as primary notification is sent to only that email or else if nothing is selected as primary it sends a notification to the very first one in the list.

I think if there is a way to activate notification for all emails in the list. it will be great.

Thank you

I understand your issue, but this isn’t a feature that SuiteCRM already has so you can simply activate it :frowning:

You need to change the code slightly. I see several people in these forums asking for such a feature, but unfortunately it doesn’t seem they have the ability to code it…

@pgr I have studied the possibility to do it in Campaigns but the code is VERY difficult to understand. There are many files involved and most of the things the code does are very difficult to reverse engineer into an understandable flowchart.

This feature is spread around several parts of the whole application so touching something may affect other parts without realising it until the problem arises.

With respect to campaigns I also tried to develop a new campaigns module to get rid of the limitations and the flaws intrroduced when it was first deveolped by SugarCRM, but, again, I have very limited time and I have given up for the moment.

It would be nice if we could form a group of a few coders to reengineer together certain parts of the code such as, for example adding the possibility to have more flexibility at the record level (account, contact, etc…) to which email(s) send certain messages as well as add certain default rules (eg: for this person send to all addresses if it is a campaign and only to the selected addresses if it’s an email: so a list of available addresses should be proposed; and to other addresses if it is notifications). Furthermore the rules could also define that certain contacts should never by default certain newsletters, but in the campaign we should be able to decide to override this option: if I have a list of VIP persons I don’t want to bother them by default, but if I organise a gala dinner with the Queen, I would like to invite them! Etc…

The way it is now it is very difficult to modify substantially and since email has been undergoing major changes it is the last part to touch until it is stable (and, unfortunately, from the comments I see there are quite a few issues to be fixed).

Email fields the way they are (multiple emails for contacts and accounts) should be available also via Studio and the rest of the application, but they aren’t. Thisn is another part to improve. For example: in Italy companies are obliged to have a “registered” email address, which can communicate only with other registered email addresses. SuiteCRM cannot handle a second email address field with similar functionality, so, for the moment we are using a text field…

I agree with you, now is not the time for adventures with email module. I think that after a dozen or so critical bugfixes, and after adding more acceptance tests, we can build up the confidence to start refactoring more seriously.

If we can come up with a group of devoted developers now, I would apply their efforts, initially, to writing tests. If test coverage for Emails and Campaigns was 100% we would be in a much better position that we are now.

I also agree that these are the areas of SuiteCRM where it’s worth to add functionality (like the ones you suggest from your real-life experience), we should make sure it is a really strong and complete product for Campaigns.

@pgr,

Hi there,

I understand that we need code it get a workaround. This is something we need on priority. Can you please help me, I’ve got a developer on board now but he needs to know where exactly we need code it or change the code in which file. The flow of code is very complicated and nearly impossible to understand.

If you can tell us where we can code it or suggest few tips. Maybe we can find the solution and have this issue resolved.

Thank you

If sending Email from Workflow, probably it’s here

https://github.com/salesagility/SuiteCRM/blob/master/modules/AOW_Actions/actions/actionSendEmail.php#L294

Hi Thanks for the help. We are working on it to see if there is any possibility.

Can you please tell if using this file we can add one of custom email field to this drop-down list (attached image).

https://pasteboard.co/Hpq9XYr.png

Currently, there are following items in this list.

Accounts: Account Name
Accounts: Account Name
Contacts: Contacts
Contacts: Created By Contact
Users: Assigned to
Users: Created By
Users: Modified By Name

I have no idea, it’s the first time I’m looking at this code.

It seems there is code to fetch the primary email address of related beans, I don’t know if you can tweak that.

In the controller.php AOW_Workflow module

SuiteCRM Git - controller.php

protected function action_getModuleField()
    {
        if(isset($_REQUEST['view'])) $view = $_REQUEST['view'];
        else $view= 'EditView';
        if(isset($_REQUEST['aow_value'])) $value = $_REQUEST['aow_value'];
        else $value = '';
        echo getModuleField($_REQUEST['aow_module'],$_REQUEST['aow_fieldname'], $_REQUEST['aow_newfieldname'], $view, $value );
        die;
    }

Use workflow to build email address in a custom field, then add modification of above? to retrieve custom field. Shooting in the dark a bit.

Some possibly useful grep output. References AOW Action to Email “Record Email”

./modules$ grep -r -B 2 -A 2 ‘Record Email’
AOW_Actions/actions/actionSendEmail.js- showElem(“aow_actions_param_email_target”+ln);
AOW_Actions/actions/actionSendEmail.js- hideElem(“aow_actions_email_user_span”+ln);
AOW_Actions/actions/actionSendEmail.js: }else if(elem.value === ‘Record Email’){
AOW_Actions/actions/actionSendEmail.js- hideElem(“aow_actions_param_email”+ln);
AOW_Actions/actions/actionSendEmail.js- hideElem(“aow_actions_param_email_target”+ln);

AOW_Actions/actions/actionSendEmail.php- $email_templates_arr = get_bean_select_array(true, ‘EmailTemplate’, ‘name’, ‘’, ‘name’);
AOW_Actions/actions/actionSendEmail.php-
AOW_Actions/actions/actionSendEmail.php: if(!in_array($bean->module_dir,getEmailableModules())) unset($app_list_strings[‘aow_email_type_list’][‘Record Email’]);
AOW_Actions/actions/actionSendEmail.php- $targetOptions = getRelatedEmailableFields($bean->module_dir);
AOW_Actions/actions/actionSendEmail.php- if(empty($targetOptions)) unset($app_list_strings[‘aow_email_type_list’][‘Related Field’]);

AOW_Actions/actions/actionSendEmail.php- }
AOW_Actions/actions/actionSendEmail.php- break;
AOW_Actions/actions/actionSendEmail.php: case ‘Record Email’:
AOW_Actions/actions/actionSendEmail.php- $recordEmail = $bean->emailAddress->getPrimaryAddress($bean);
AOW_Actions/actions/actionSendEmail.php- if($recordEmail == ‘’ && isset($bean->email1)) $recordEmail = $bean->email1;

AOW_WorkFlow/controller.php-
AOW_WorkFlow/controller.php- switch($_REQUEST[‘aow_type’]) {
AOW_WorkFlow/controller.php: case ‘Record Email’;
AOW_WorkFlow/controller.php- echo ‘’;
AOW_WorkFlow/controller.php- break;

Should I change this with my module names

aow_module
aow_fieldname
aow_newfieldname

I’m not sure, was just a guess as a starting point for your developer. I haven’t messed with a lot of the Workflow code.

The grep output that I posted points at three files which grab the Record Email. Probably start there and look at what those files are doing to retrieve the record email, and use that to get a different field that you specify. I’ll mess with it more as time permits.

Hi Can anybody help me I just need a simple logic hook to sent email?

We have tried many things but seems to be failed. I need a logic hook to run when a case is updated. It should send an email to a custom field of cases module

Thank you in advance

Have alook at this example:
https://github.com/audoxcl/SugarCRMLogicHooks