How to Create Email Field in Custom Module

Hi Actually I create one module from Studio and keep module type is file.

Now I need an Email Address Field in this module. So can anyone help me how to solve this issue.

Any help will be appreciating.

Thanks
Parents Reply Children
  • Good to know that :).

    Rolustech: SugarCRM Engineering
    Website: www.rolustech.com
    Ph (US): +1 - 310 - 492 - 5564
    Ph (UK): +44 - 207 - 9938 - 524
    Email: info@rolustech.com
    Skype: rolustech
  • Hello Rolustech,

    I try to make mobile field same as email field can you help me.
  • We needed this in sugar 7 (onsite 7.5.1) too.  We got it working but are not 100% sure how good it is. We roughly followed the two links above but found that,

    1. in the record.php we needed to set the type to 'email' in order for the sugar 7 email address UI to kick in. 

     7 => array (
                    'name' => 'email',
                    'type' => 'email',
                    'span' => 6,
                  ),


    Also 2.  the object constructed we think should be EmailAddress not the old legacy SugarEmailAddress,

    public function __construct(){
            parent::__construct();
                    $this->emailAddress = new EmailAddress(); //xxx #xxxx not old SugarEmailAddress which doesn't have extended method DeleteLinks.  Now matches Accounts.
        }

    3.   As well as defining the email1 field we defined email and used that.  We got all of these from
    include/SugarObjects/implements/email_address/vardefs.php

     $dictionary[$module]['fields']['email'] =  array(
        'name' => 'email',
        'type' => 'email',
        'query_type' => 'default',
        'source' => 'non-db',
        'operator' => 'subquery',
        'subquery' => 'SELECT eabr.bean_id FROM email_addr_bean_rel eabr JOIN email_addresses ea ON (ea.id = eabr.email_address_id) WHERE eabr.deleted=0 AND ea.email_address LIKE',
        'db_field' => array(
            'id',
        ),
        'vname' => 'LBL_EMAIL', //'LBL_ANY_EMAIL',
        'studio' => array('visible'=>false, 'searchview'=>true),
        'duplicate_on_record_copy' => 'always',
        'len' => 100,
        'sort_on' => 'email1',
        'importable' => false,
    );
    etc.
    Remaining issue: We can't get the email field to show up in searches.

    UPDATE: I suspect we didn't need to do all of this!    Later I noticed 'uses' in the Accounts vardef to make use of the 'templates' (i.e. it seems to be the way to add the implements code we copied from above to a module).  Or potentially if you have a createVardef line you could specify the email_address template should be used,
    VardefManager::createVardef('cost_Cost_Centre','cost_Cost_Centre', array('basic','team_security','assignable', 'email_address'));
    Has anyone tried this or have any better information on how to do add an email to a custom sugar module in sugarcrm 7???