How to add new field in Email Template Module

Hello,

SuiteCRM Version 7.11.3

How we can add new field in Email Template module. I tried to add from studio but it didnt work.

Can anyone guide.

Thanks
Jyoti

Hi

did you try to modify the template module direct from Email Templates?

Hi,

Yes, I am trying from files, somehow able to add field but it’s values is not getting save in database .

Thanks

What exactly do you mean by this?

To add a new variable, it needs to be referenced in the template, but it also needs to be assigned first in the code.

yes i did it from code.

Thanks

  1. Create Custom Field Programmatically

Create File for Field
File Path : custom/Extension/modules/EmailTemplates/Ext/Vardefs/emailtemp_name.php

$GLOBALS['dictionary']['EmailTemplate']['fields']['emailtemp_name'] = array (
	'name' => 'emailtemp_name',
           'vname' => 'LBL_EMAIL_TEMPLATE_NAME',
	'type' => 'varchar',
	'module' => 'EmailTemplates',
	'help' => 'Text Field Help Text',
	'comment' => 'Text Field Comment Text',
	'default_value' => '',
	'max_size' => 255,
	'required' => false, // true or false
	'reportable' => true, // true or false
	'audited' => false, // true or false
	'importable' => 'true', // 'true', 'false', 'required'
	'duplicate_merge' => false, // true or false
);

Create Language file for Field
File Path : custom/Extension/modules/EmailTemplates/Ext/Language/en_us.emailtemp_name.php

$mod_strings['LBL_EMAIL_TEMPLATE_NAME'] = 'Email Template Name';

After Creating above two files, Do Repair & Rebuild and you should be prompted to add emailtemp_name to the database.

  1. Manually Add Your field HTML because Email Templates Modules Layout is predefined and hardcoded maintain in file,

    File Path : modules/EmailTemplates/EditViewMain.html

    Put the code below in the

    tag of the table where you want to add the custom field.
    <td width="15%" scope="row">
        Email Template Name //Use Language file for label. Currently i put static
    </td>
    <td width="30%" >
        <input  id='emailtemp_name' name='emailtemp_name' tabindex="0" type="text" size='30' maxlength="255" value="{EMAILTEMPNAME}">
    </td>
    
    1. Assign Custom Field Value to the EditViewMain.html file for auto fill value in EditView Layout

      File Path : modules/EmailTemplates/EditView.php

      Put the below code in EditView.php file,

    if (isset($focus->emailtemp_name)) {
        $xtpl->assign("EMAILTEMPNAME", $focus->emailtemp_name);
    } else {
    	$xtpl->assign("EMAILTEMPNAME", "");
    }
    

    I hope will help you

1 Like

Thanks Urvi, It’s working perfectly :slight_smile:

Thank You
Its my pleasure
please feel free to ask me if you still have any questions

Hi,

I want to change default style of layout. Is it possible? Like font family, size.