Results 1 to 2 of 2

Thread: Any Way to Control (Inbound Email Created) Case Details?

  1. #1
    machineghost is offline Senior Member
    Join Date
    Oct 2008
    Posts
    51

    Default Any Way to Control (Inbound Email Created) Case Details?

    I just discovered the SugarCRM inbound email => new case feature, and I love it. Previously we had a custom-written Perl script that created records in a Bugzilla database, and while that did work it was much, much messier than the Sugar solution.

    However, I do have a problem: there doesn't appear to be any way to control the details of the case that Sugar creates in response to an inbound email. For instance, if I create "category-1-issues@" and "category-2-issues@" email addresses, and feed them in to Sugar, there seems to be no way to specify that emails from the first address should have a category of "Category 1", while emails from the second should instead have a category of "Category 2".

    So, my question is: can I control these details somehow by manually editing the PHP files, and if so can anyone point me towards what files/how I would do so? I don't need step-by-step instructions or anything (unless you are super-generous and have lots of free time), just basic details to get me started would be greatly appreciated.

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Any Way to Control (Inbound Email Created) Case Details?

    I'm sure you could use logic hooks for this. We wanted to check a checkbox anytime an email came in so we created two files in custom/modules/Emails:

    logic_hooks.php (hook definition file):
    PHP Code:
    <?php
    // Do not store anything in this file that is not part of the array or the hook version.  This file will    
    // be automatically rebuilt in the future. 
     
    $hook_version 1
    $hook_array = Array(); 
    // position, file, function 
    $hook_array['before_save'] = Array();
    $hook_array['before_save'][] = Array(6'flag_new_email_history''custom/modules/Emails/NewEmailHistory.php','NewEmailHistory''flag_new_email_history'); 

    ?>
    NewEmailHistory.php:
    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');


    class 
    NewEmailHistory {

    function 
    flag_new_email_history(&$bean$event$arguments)
    {
        
    //$GLOBALS['log']->fatal("flag_new_email_history");
        
    require_once('modules/Emails/Email.php');
        require_once(
    'modules/Cases/Case.php');

        
    //get id...if not set then it is a new record so create an id here
        
    if(empty($bean->id)) {
            
    $bean->id create_guid();
            
    $bean->new_with_id true;
        }

        
    /** for inbound emails */
        
    if(isset($bean->parent_type) && $bean->parent_type == 'Cases' && !empty($bean->parent_id)
            && 
    $bean->type != "archived" && strpos($bean->name,"[Case:") !== false
        
    ) {    
            
    //$GLOBALS['log']->fatal("setting new history flag");
    /**
    //triggers more logic hooks which we don't want so manually run the update query instead
            $case = new aCase();
            $case->retrieve($bean->parent_id);
            $case->new_history_c = '1';
            $case->save();
    */
            
    require_once('include/utils.php');
            global 
    $db;
            
            
    $query "UPDATE cases_cstm SET new_history_c = '1' where id_c = '".$bean->parent_id."'";
            
    $db->query($query,true,"Error seting email new history for case: ".$bean->parent_id);
            
        }




    }
    ?>
    With some creativity you should be able to do what you need.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 11
    Last Post: 2009-02-26, 07:42 AM
  2. Inbound email case creation
    By speed in forum Help
    Replies: 4
    Last Post: 2009-01-06, 11:12 PM
  3. automatic case from inbound email
    By domenico1983 in forum Help
    Replies: 27
    Last Post: 2008-07-10, 04:16 PM
  4. Send email to Contact when a Case is created
    By MichaelRLevy in forum Help
    Replies: 1
    Last Post: 2007-09-27, 10:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •