hi, I am new to suitecrm. I’ve tried to create an address field for my projects and it is not created like in the accounts or leads modules address which is already present. it was displayed like a normal text filed. how do achieve this? someone, please help me with this
Here’s how you can add address to a custom module. I did it for Products (AOS_Products) module
custom/Extension/modules/AOS_Products/Ext/Vardefs/primary_address.php
<?php
$dictionary['AOS_Products']['fields']['billing_address_street'] =
array (
'name' => 'billing_address_street',
'vname' => 'LBL_BILLING_ADDRESS_STREET',
'type' => 'varchar',
'len' => '150',
'comment' => 'The street address used for billing address',
'group' => 'billing_address',
'merge_filter' => 'enabled',
);
$dictionary['AOS_Products']['fields']['billing_address_city'] =
array (
'name' => 'billing_address_city',
'vname' => 'LBL_BILLING_ADDRESS_CITY',
'type' => 'varchar',
'len' => '100',
'comment' => 'The city used for billing address',
'group' => 'billing_address',
'merge_filter' => 'enabled',
);
$dictionary['AOS_Products']['fields']['billing_address_state'] =
array (
'name' => 'billing_address_state',
'vname' => 'LBL_BILLING_ADDRESS_STATE',
'type' => 'varchar',
'len' => '100',
'group' => 'billing_address',
'comment' => 'The state used for billing address',
'merge_filter' => 'enabled',
);
$dictionary['AOS_Products']['fields']['billing_address_postalcode'] =
array (
'name' => 'billing_address_postalcode',
'vname' => 'LBL_BILLING_ADDRESS_POSTALCODE',
'type' => 'varchar',
'len' => '20',
'group' => 'billing_address',
'comment' => 'The postal code used for billing address',
'merge_filter' => 'enabled',
);
$dictionary['AOS_Products']['fields']['billing_address_country'] =
array (
'name' => 'billing_address_country',
'vname' => 'LBL_BILLING_ADDRESS_COUNTRY',
'type' => 'varchar',
'group' => 'billing_address',
'comment' => 'The country used for the billing address',
'merge_filter' => 'enabled',
);
custom/Extension/modules/AOS_Products/Ext/Language/en_us.primary_address.php
<?php
$mod_strings['LBL_BILLING_ADDRESS_CITY'] = 'Billing City:';
$mod_strings['LBL_BILLING_ADDRESS_COUNTRY' ]= 'Billing Country:';
$mod_strings['LBL_BILLING_ADDRESS_POSTALCODE' ]= 'Billing Postal Code:';
$mod_strings['LBL_BILLING_ADDRESS_STATE' ]= 'Billing State:';
$mod_strings['LBL_BILLING_ADDRESS_STREET' ]= 'Billing Street:';
$mod_strings['LBL_BILLING_ADDRESS' ]= 'Billing Address:';
custom/modules/AOS_Products/metadata/detailviewdefs.php
<?php
$module_name = 'AOS_Products';
$viewdefs [$module_name] =
array (
'DetailView' =>
array (
'templateMeta' =>
array (
'form' =>
array (
'buttons' =>
array (
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
),
),
'maxColumns' => '2',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
),
'useTabs' => true,
'tabDefs' =>
array (
'DEFAULT' =>
array (
'newTab' => true,
'panelDefault' => 'expanded',
),
),
),
'panels' =>
array (
'default' =>
array (
//other fields here
6 =>
array (
0 =>
array(
'name' => 'billing_address_street',
'label' => 'LBL_BILLING_ADDRESS',
'type' => 'address',
'displayParams' =>
array(
'key' => 'billing',
),
),
1 => '',
),
),
),
),
);
;
?>
custom/modules/AOS_Products/metadata/editviewdefs.php
<?php
$module_name = 'AOS_Products';
$viewdefs [$module_name] =
array (
'EditView' =>
array (
'templateMeta' =>
array (
'maxColumns' => '2',
'widths' =>
array (
0 =>
array (
'label' => '10',
'field' => '30',
),
1 =>
array (
'label' => '10',
'field' => '30',
),
),
'form' =>
array (
'enctype' => 'multipart/form-data',
'headerTpl' => 'modules/AOS_Products/tpls/EditViewHeader.tpl',
),
'includes' =>
array (
0 =>
array (
'file' => 'modules/AOS_Products/js/products.js',
),
),
'useTabs' => false,
'tabDefs' =>
array (
'DEFAULT' =>
array (
'newTab' => false,
'panelDefault' => 'expanded',
),
),
),
'panels' =>
array (
'default' =>
array (
// other fields here
6 =>
array (
0 =>
array (
'name' => 'billing_address_street',
'hideLabel' => true,
'type' => 'address',
'displayParams' =>
array(
'key' => 'billing',
'rows' => 2,
'cols' => 30,
'maxlength' => 150,
),
),
1 => '',
),
),
),
),
);
;
?>
Do remember to repair and rebuild and execute the queries after the repair and rebuild
Hi @sureshkmr , that’s an way to create this field using studio in suiteCRM…
If you need to create a specific adress field at any module, you can do it just like the picture indicates.
Hope that helps, thanks!
these are the screenshots of how I created a field for address. but in the layout, I didn’t get the output as I expected(billing address which is in the Products). @abuzarfaris as per your guidelines I didn’t get my custom modules(Agencies) in the custom/Extension directory
please help me with this.
Thankyou.
If the folder is not there you can create it since you are using suitecrm 8
the address will be something like
public/legacy/custom/Extension/modules/AOS_Products/Ext/Vardefs/primary_address.php
and so on for other files as well
I haven’t tested with suitecrm 8 but it should work