add custom filed in contact module

Hello,

I have added a custom field in “Contacts” module name as ‘blog_site_name’, From following path "Studio > Contacts > Fields > ADD FIELD ", But in a database that custom field added in Contatcs_cstm table Instead of Contacts table.

I Just want to add a custom field in Contacts table, Instead of Contacts_cstm table.

Could you please anyone guide me how to archive this?

Thanks in advanced.

The system is buit in a way that custom fields are added to the _cstm table.

You may do it programmatically but it may not be upgrade safe.

May I ask why you want it in the contacts table instead of the contacts_cstm table? You shouldn’t notice the difference.

We are accessing fields of suitecrm using direct datbase query,
We are suppose to add one field in all module and this field should be in main table,so that we can create dynamic quey where we need to pass only main table name.

Do you have any idea for the same?
Thanks

If I were you, given the little use you need ift for, I would elaborate the dynamic query to include the custom fields table. It is very simple because each record in the standard table has another record in the custom table containing all the custom fields. The common field is the id, which is the same in both sides.

For example, to select all the contacts:

$table_name = 'contacts';
$query = "select * from ". $table_name ." inner join ". $table_name ."_cstm on ". $table_name .".id = ". $table_name ."_cstm.id_c";

For example, to select all not deleted contacts:

$table_name = 'contacts';
$query = "select * from ". $table_name ." inner join ". $table_name ."_cstm on ". $table_name .".id = ". $table_name ."_cstm.id_c WHERE ". $table_name .".deleted= '0' ";

or, to select one contact:

$table_name = 'contacts';
$record_id = 'c255215a-5678-53a9-3026-4fbac3f9ba48';
$query = "select * from ". $table_name ." inner join ". $table_name ."_cstm on ". $table_name .".id = ". $table_name ."_cstm.id_c WHERE ". $table_name .".id = '". $record_id ."'";

In my opinion the simplicity of these (dynamic) queries doesn’t justify to use the standard table.

To complete your code you may also check if the corresponding table ending with _cstm exists and then decide whether to build the query with the join or without it.