@p.konetskiy
You have a way of understating ⌠
Definitely an interesting task.
I cannot match your success even after duplicating what worked for you.
Question: Does the $dictionary[ââ][âcustom_fieldsâ] = true; declaration go into custom/Extension/modules//Ext/Vardefs/.php ?
That is where I tried putting it.
I tried adding, to custom/Extension/modules/FP_events/Ext/Vardefs/setCustomFlag.php
<?php
$dictionary['FP_events']['custom_fields'] = true;
to see if doing that enabled QR&R to create the custom field from the following vardef in custom/Extension/modules/FP_events/Ext/Vardefs/maybe_c.php
<?php
$dictionary['FP_events']['fields']['maybe_c'] = array(
'name' => 'maybe_c',
'vname' => 'LBL_MAYBE',
'type' => 'varchar',
'len' => '255',
'size' => '20',
'source' => 'custom_fields',
'custom_module' => 'FP_events',
'id' => 'FP_eventsmaybe_c',
'help' => '',
'comments' => '',
'default' => '',
'no_default' => true,
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'required' => false,
'inline_edit' => '',
'massupdate' => '0',
'audited' => false,
'reportable' => true,
'importable' => 'true',
'unified_search' => false,
'merge_filter' => 'disabled',
'studio' => 'visible',
);
There is an entry for FP_events in the fp_events_cstm table in the database from previously adding fields to FP_events via Studio and via the method in the above post.
There are previous entries in fields_meta_table for FP_events from previously adding fields to FP_events via Studio and via the method in the above post.
After QR&R the maybe_c field definition was added to custom/modules/FP_events/Ext/Vardefs/vardefs.ext.php
But, after the QR&R, nothing was added to either of the fields_metda_data or fp_events_cstm databae tables. I did try running QR&R twice
So I then tried adding the same field definition - edited for Contacts - to the the Contacts vardefs in custom/Extension/modules/Contacts/Ext/Vardefs/maybe_c.php
<?php
$dictionary['Contact']['fields']['maybe_c'] = array(
'name' => 'maybe_c',
'vname' => 'LBL_MAYBE',
'type' => 'varchar',
'len' => '255',
'size' => '20',
'source' => 'custom_fields',
'custom_module' => 'Contacts',
'id' => 'Contactsmaybe_c',
'help' => '',
'comments' => '',
'default' => '',
'no_default' => true,
'duplicate_merge' => 'disabled',
'duplicate_merge_dom_value' => '0',
'required' => false,
'inline_edit' => '',
'massupdate' => '0',
'audited' => false,
'reportable' => true,
'importable' => 'true',
'unified_search' => false,
'merge_filter' => 'disabled',
'studio' => 'visible',
);
As you said, there were already entries in contacts_cstm and fields_meta_data for Contacts.
After a QR&R, nothing was added to fields_meta_data or contacts_cstm
So I THINK I am doing the same as you but I am not getting the same results as you.
I got my vardef parameters by looking at the cache/modules/FP_events/FP_eventsvardefs.php so I think I am using the right vardefs definition, but do you see anything in my vardef that would be preventing what I am doing from working with vardefs?
Just to see if my system was totally messed up, I tried adding a custom field to each of FP_events and Contacts using the programatic method described above and it worked, with 2 new entries in fields_meta_data and a new entry in each of fp_events_cstm and contacts_cstm
Create a new file in {SuiteCRM_Directory}/addCustomFields.php with
<?php
if(!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
$fields = array ();
$fields[] = array(
// Text Field
'name' => 'maybe2_c',
'label' => 'LBL_MAYBE2',
'type' => 'varchar',
'module' => 'FP_events',
'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
);
$fields[] = array(
// Text Field
'name' => 'maybe2_c',
'label' => 'LBL_MAYBE2',
'type' => 'varchar',
'module' => 'Contacts',
'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
);
require_once('ModuleInstall/ModuleInstaller.php');
$newInstallerBean = new ModuleInstaller();
$newInstallerBean->install_custom_fields($fields);
// Return the user to the Administration menu
SugarApplication::redirect('index.php?module=Administration&action=index');
Enable that file to be an entry point by adding the file at custom/Extension/application/Ext/EntryPointRegistry/addCustomFieldsEntryPoint.php
<?php
$entry_point_registry['addCustomFieldsEntryPoint'] = array(
// Pointer to the location of the file for which this EntryPoint is defined
'file' => 'addCustomFields.php',
// auth true means person using the EntryPoint must be an authenticated User
// auth false means anyone could the EntryPoint - NOT a good idea usually
'auth' => true,
);
Quick Repair and Rebuild
Point my browser to the EntryPoint at
{SuiteCRM_URL}/index.php?entryPoint=addCustomFieldsEntryPoint
and yes, the maybe2_c custom fields were created in fields_meta_data, fp_events_cstm and contacts_cstm
So this is DEFINITELY getting interesting.
I cannot get to work what works on your system
And you cannot get to work what works on my system
Maybe we should take our 2 systems and send them to counselling so they can agree ⌠
Any ideas?