by eggsurplus

Control what your users can access and save time, money, and frustrations. Lock down sensitive data in SugarCRM or SuiteCRM to specific groups or teams. Supports unlimited assigned users, unlimited group assignments to records, custom layouts for each group, login/sudo capabilities and much more.

Cancel at any time!
Free Trial

#19 - Email Addresses In Email Template

Closed Feature created by jbaranello 6 years ago

Hi,

I was wondering if it is possible to create an email template where the distribution list is essentially the emails from the members of the team that are completing the project. Sorry if I missed anything in advance!!

Im running Sugar CE 6.5.7 with Workflow Manager. My email template is essentially complete, just need to dynamically add the email addresses.

FYI, great module!!!!!!!

Thanks

  1. eggsurplus member avatar

    eggsurplus Provider Affiliate

    6 years ago

    I'm not exactly sure how Workflow Manager works when it comes to sending, but it is fairly straight forward on how to get all members of a group. You can even use the getMembers() function in modules/SecurityGroups/SecurityGroup.php to get each member. Then grab the User bean to get the email address to send to.

  2. jbaranello member avatar

    jbaranello

    6 years ago

    Hey,

    Thanks for the quick response. I don't think I asked the question right. In the workflow manager there is a section that asks you to supply the recipients of the emai. In workflow manager it is possible to call on bean variables directly in the textbox where you put the distribution list. I was just wondering what would the bean variable be to call in order to get the email addresses of the users that are part of the security group. Keep in mind this email is generated when a modify event takes place on a project. Thus the bean variables for that project object are available to use. Is there any variable/variables I can use to accomplish this??

    Thanks

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      6 years ago

      That's interesting. There isn't anything out of the box, but I wonder if it is possible to jury rig your own. Not sure how comfortable with code you are, but you may be able to create a non-db field in the SecurityGroups module that pulls an array of email addresses for you. Not sure if the Workflow Manager tool accepts an array of emails or not. I haven't had a specific request for something that works with Workflow Manager but there are a few out there that just pull the email addresses in their own logic hooks using the method I described previously.

  3. jbaranello member avatar

    jbaranello

    6 years ago

    Im comfortable with code in general lol just haven't really had any experiance doing coding with SugarCRM. Thing is I don't know how I would get the emails to be inserted into workflow. The only supported way is what I described to you, write the bean variable directly in the "To:" field. An example of what I used in the Subject line is as follows:

    ${bean->name} project has been modified.
    Where ${bean->name} displays the name of the project that was modified.

    I have a feeling the variable you insert in the "To:" field will just need to be a string with the email addresses seperated with a "," and that should be ok. The only issue I have is how to get the bean variables I NEED to load with the Project Object as those are the variables i have access to when this modify_event occurs.

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      6 years ago

      I think you could do this by adding a custom field to the Project module, make it a non-db field, and define a function for it like I've posted here: http://www.eggsurplus.com/home/content/populate-a-dropdown-from-the-database/

      Then you can do the logic in the function to make that comma separated list of email addresses that pulls from the group(s) associated to the project.

  4. jbaranello member avatar

    jbaranello

    6 years ago

    OK cool, I'll give the link a look and see if I can implement. I'll keep you posted.

    Thanks

  5. jbaranello member avatar

    jbaranello

    6 years ago

    Hi,

    I am having a lil trouble with finding the correct syntax for a few items. In order to use your getMembers() function, what are the requirements?? Does it need to be called as follows getMembers(SecurityGrpName)??

    Essentially this is my plan:

    1 - Create New Variable in vardef and vardef.ext in /modules/Project and /custom/modules/Project/Ext/Vardefs respectively using the following definition:

                        'grp_email_list' => array ( 
                'name' => 'grp_email_list', 
            'vname' => 'Security Group E-Mail List', 
                'type' => 'function', 
                'source' => 'non-db', 
            'function_name' => 'get_grp_emails', 
                'function_params' => "Variable in Project Object for Group Names"
                'function_params_source' => 'this', 
                'function_require' => 'custom/Extension/modules/Project/Ext/GetGrpEmails.php',
    

    Still not too sure about how to use the 'function_params', I am assuming its like specifying input variables for the function to use, is this correct?? Which variable would I use to get the array of security group names related the project??

    Also would I just stick this definition anywhere in the vardef files??

    2 - Create Function in GetGrpEmail.php

    This is what I have so far, not to sure if syntax is right or if it is right at all lol. Maybe you could give a look. The only thing I haven't accounted for is if there will be duplicate names (users in more then one group assigned to project).

    <?php // Function to get and reformat Security Group Member Emails function get_grp_emails($grp_name_array) { // Define Empty Array and String Variable $user_array[] = array(); $vStringEmails = ""; //Get List of Users for All Assigned Secuity Groups and Append to Array foreach($grp_name_array as $val) { $user_array[] = getMembers($val); // Not sure if this will work if $val is an array, can you // confirm?? I read that this is the correct syntax if you just want // to append one item at a time to end of array. } //Get Email for Every User in $user_array and Store in Appropriate Format foreach($user_array as $val) { // Initialize Variable $user_email = ""; // Get User Email from Bean Variables $user_email = // Not to sure how to get those?? Couldn't find anything online. // Append to String to Use in Ditribution List $vStringEmails = $vStringEmails . $user_email; $vStringEmails = $vStringEmails . ","; } return ($vStringEmails); } ?>

    This is what I have so far. Once I am finished coding these I will attempt to add a custom field using Studio.

    Thank in advance for your help.

    Jason

    • eggsurplus member avatar

      eggsurplus Provider Affiliate

      6 years ago

      To use getMembers() it would be something like:
      require_once('modules/SecurityGroups/SecurityGroup.php');
      require_once('modules/Users/User.php');
      $group = new SecurityGroup();
      $group->retrieve($group_id);
      $members = $group->getMembers();
      foreach($members as $member) {
      $user = new User();
      $user->retrieve($member->id);
      if(!empty($user_email)) $user_email .= ','; //assumes $user_email defined above
      $user_email .= $user->email1;
      }

      I'm not sure on the vardef that you have there. It may work, but not familiar with it. I'd use a type = 'text' and set the function key as in this post: http://www.eggsurplus.com/home/content/populate-a-dropdown-from-the-database/

      Notice the file paths used in it. It does require a Repair/Rebuild after any edit to those files. Notice that the utils function is defined in the application path.

  6. eggsurplus member avatar

    eggsurplus Provider Affiliate

    6 years ago

    I'm going to close this as it pertains to a custom need versus something that isn't working. However, I hope you got what you need working. Feel free to share here what you ended up doing if you did get it going.

This case is public. Please leave out any sensitive information such as URLs, passwords, etc.
Saving Comment Saving Comment...
Rating
Rating
  • "No brainer. I have purchased it for two production installations and not regretted it."

    Read More Reviews

Keep up to date on the latest additions

We'll send you an email every month with handpicked add-ons, reviews, tricks and tips. Don't worry, we hate spam as much as you do.