issue adding email field to cases module

I am trying to add the email field to the cases module, I tried to follow the Adding the Emails Field to the Record View from the sugar developer guide and everything seemed to work well, the field appears but when the record is saved it throw me the following error: 

  

HTTP: 500 Internal Server Error

An exception occurred while executing 'SELECT jt0_email_addresses_primary.email_address email FROM cases LEFT JOIN email_addr_bean_rel cases_email_addresses_primary ON (cases_email_addresses_primary.deleted = ?) AND (cases_email_addresses_primary.bean_module = ?) AND (cases_email_addresses_primary.primary_address = ?) LEFT JOIN cases jt0_email_addresses_primary ON (jt0_email_addresses_primary.id = cases_email_addresses_primary.bean_id) AND (jt0_email_addresses_primary.deleted = ?) LEFT JOIN cases_cstm cases_cstm ON cases_cstm.id_c = cases.id WHERE (cases.id = ?) AND (cases.deleted = ?) LIMIT 1' with params [0, "Case", 1, "0", "6d64d318-2e86-11eb-bfbb-02df47d122c6", 0]: Unknown column 'jt0_email_addresses_primary.email_address' in 'field list'

I don't know what can be, if anyone have an idea is welcome, thanks for helping

Parents
  • Looks like the field was not created in the cases database table.

    Try to run a quick repair and rebuild and make sure that the proposed SQL command will be executed correctly. Sometime you have to delete the comments before the ALTER TABLE statement.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • Hi Harald,

    thanks for answer

    I already did that, but it's not working

    Regards.

  • So you created the email fields as non-db in your vardef file but the code supposes them to be db fields.

    Did you create and install the custom Bean as written in the blog post?

    Did you notice that the object name of Cases is aCase ? That means that \custom\modules\Cases\CustomCase.php starts with

    <?php
    
    class CustomCase extends aCase
    {
        /**
         * Constructor
         */
        public function __construct()
        {
            parent::__construct();
            $this->emailAddress = BeanFactory::newBean('EmailAddresses');
        }
    

    custom\Extension\application\Ext\Include\customCases.php must contain (not aCase but Case in $objectList):

    <?php
    
    $objectList['Cases'] = 'Case';
    $beanList['Cases'] = 'CustomCase';
    $beanFiles['CustomCase'] = 'custom/modules/Cases/CustomCase.php';

    Case is a keyword within php, so it cannot be the name of class.

    I tested it locally and it worked fine:

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

Reply
  • So you created the email fields as non-db in your vardef file but the code supposes them to be db fields.

    Did you create and install the custom Bean as written in the blog post?

    Did you notice that the object name of Cases is aCase ? That means that \custom\modules\Cases\CustomCase.php starts with

    <?php
    
    class CustomCase extends aCase
    {
        /**
         * Constructor
         */
        public function __construct()
        {
            parent::__construct();
            $this->emailAddress = BeanFactory::newBean('EmailAddresses');
        }
    

    custom\Extension\application\Ext\Include\customCases.php must contain (not aCase but Case in $objectList):

    <?php
    
    $objectList['Cases'] = 'Case';
    $beanList['Cases'] = 'CustomCase';
    $beanFiles['CustomCase'] = 'custom/modules/Cases/CustomCase.php';

    Case is a keyword within php, so it cannot be the name of class.

    I tested it locally and it worked fine:

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

Children