How to add custom fields to Grouped Address field

I’m trying to add custom address fields to the grouped address field (billing address) within my Accounts module. I did some research on the internet and theoretically this should be possible by beginning the field name of each custom field with “billing_address”, however according to this post (http://stackoverflow.com/questions/11695599/how-to-add-additional-grouped-address-to-edit-and-detail-view) there’s a bug in the Sugar code and as a result this doesn’t work for custom fields.

I can find very little information about this issue, and about this bug, on the internet and the links mentioned in the stackoverflow post are not working anymore. I tried what’s suggest in that post, to remove the _c part for the fields in the vardefs and in the database but once I do a Repair Sugar keeps complaining that there is a mismatch between the vardefs and the database as somehow there is still a vardef definition of my column with the _c part. I changed the vardef at this location: /var/www/html/sugar_test/custom/Extension/modules/Accounts/Ext/Vardefs

If anyone can tell me how to do this properly that would be much appreciated!

Hi,

can you show the vardef of your field? What kind of field type would you like to add?

Hi, I’m trying to add a Fax Number field to the Billing Address group. I’ve created the the field through Studio and consequently in ‘custom/Extension/modules/Accounts/Ext/Vardefs’ a file called ‘sugarfield_billing_address_fax_c.php’ is generated.

The contents of this file is as follows:


$dictionary['Account']['fields']['billing_address_fax_c']['inline_edit']='1';
$dictionary['Account']['fields']['billing_address_fax_c']['labelValue']='Billing Address Fax';

I’m not sure if this is the right place to remove the _c parts out of the field name but I’ve used the ‘grep’ command in my Linux terminal to search for all the occurrences of the ‘billing_address_fax_c’ field and this is the only non-auto-generated file where I can find this occurrence.

Hi, first: how do you plan to integrate this field in the address block?

To answer your question, the field name is stored in the database table “fields_meta_data”, so you should change it in this table as well.

Another solution is to not implement this field as a custom field, but defining it directly with vardefs by:

  • removing all vardef files that correspond to your new field
  • deleting the field in studio
  • creating the file
custom/Extension/Accounts/ext/Vardefs/billing_address_fax.php

with contents


<?php
$dictionary['Account']['fields']['billing_address_fax'] = 
	 array (
	'required' => false,
	'name' => 'billing_address_fax',
	'vname' => 'LBL_BILLING_ADDRESS_FAX',
	'type' => 'phone',
	'massupdate' => 0,
	'no_default' => false,
	'importable' => 'true',
	'duplicate_merge' => 'disabled',
	'duplicate_merge_dom_value' => '0',
	'audited' => false,
	'reportable' => true,
	'unified_search' => false,
	'merge_filter' => 'disabled',
	'len' => '255',
	'size' => '20',
	'dbType' => 'varchar',
	'inline_edit' => '1',
    );
  • create the file:
custom/Extension/Accounts/ext/Language/en_us.billing_address_fax.php

with contents


<?php
$mod_strings['LBL_BILLING_ADDRESS_FAX'] = 'Billing Address Fax:';
  • Afterwards to an Admin / Repair / Quick Repair and Rebuild and execute the SQL changes
1 Like

I tried both solutions and the fields are created in both cases (without the _c) part, however they are still not added to the Grouped Address field. In my understanding they should automatically be included in the group based on the “billing_address” key part?

Have anyone figured this out yet?

Hi,

You must “hack” de tpl of addres field and add there your new field.
There the out-of-box path SuiteCRM/include/SugarFields/Fields/Address

You can create same in custom…

Regards

Thanks. :slight_smile:

I added new field to address group successful but this field is omitted when using checkbox copy.
Any help?