Add district into address

Hi, how do I add a column for “District” in the address column for billing and shipping? Anyone can help?

You can look at this post Here

I have tried but not working.

Which module do you want to create this column?

Let’s go to the new Manual

I’m going to assume that the module is accounts

1º - Go to the folder “…\custom\Extension\modules\Accounts\Ext”
2º - Verify that a folder called “Vardefs” already exists
3º - If it does not exist, create this folder


4º - Within this folder create a file called “billing_address_district.php”
5º - In the file place the following code

<?php
$dictionary['Account']['fields']['billing_address_district'] = 
	 array (
	'required' => false,
	'name' => 'billing_address_district',
	'vname' => 'LBL_BILLING_ADDRESS_DISTRICT',
	'type' => 'varchar',
	'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' => '100',
	'size' => '20',
	'dbType' => 'varchar',
	'inline_edit' => '1',
    );

6º - Save and close the file
7º - Verify that a folder called “Language” already exists
8º - If it does not exist, create this folder
9º - Within this folder create a file called “en_us.billing_address_district.php”
10º - In the file place the following code

<?php
$mod_strings['LBL_BILLING_ADDRESS_DISTRICT'] = 'Billing Address District:';

11º - Save and close the file
12º - Now in SuiteCrm go to Admin -> Repair -> Quick Repair and Rebuild and execute the SQL changes
13º - Afterwards go to Studio -> Select Accounts -> Fields
14º - In This moment you can see that field there
15º - Now we need change other files to show this field in Account module
16º - Go to “…\include\SugarFields\Fields\Address”
17º - Change the file “EditView.tpl”
18º - Search for the line with the content

{{assign var="street" value=$displayParams.key|cat:'_address_street'}}

19º - Below it, place the following code

{{assign var="district" value=$displayParams.key|cat:'_address_district'}}

20º - Below in the file you can see that there is a table where the fields are located, choose the position where you want the district field to be and add the following code

<tr>

<td id="{{$district}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for='{{$district}}'>{sugar_translate label='LBL_ADDRESS_DISTRICT' module='{{$module}}'}:</label>
{if $fields.{{$district}}.required || {{if $district|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<input type="text" name="{{$district}}" id="{{$district}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$district}}.value}'  {{if !empty($tabindex)}} tabindex="{{$tabindex}}" {{/if}}>
</td>
</tr>

21º - Save and close the file

22º - Change the file “en_us.EditView”
23º - Search for the line with the content

{{assign var="street" value=$displayParams.key|cat:'_address_street'}}

24º - Below it, place the following code

{{assign var="district" value=$displayParams.key|cat:'_address_district'}}

25º - Below in the file you can see that there is a table where the fields are located, choose the position where you want the district field to be and add the following code

<tr>

<td id="{{$district}}_label" width='{{$def.templateMeta.widths[$smarty.foreach.colIteration.index].label}}%' scope='row' >
<label for='{{$district}}'>{sugar_translate label='LBL_ADDRESS_DISTRICT' module='{{$module}}'}:</label>
{if $fields.{{$district}}.required || {{if $district|lower|in_array:$displayParams.required}}true{{else}}false{{/if}}}
<span class="required">{$APP.LBL_REQUIRED_SYMBOL}</span>
{/if}
</td>
<td>
<input type="text" name="{{$district}}" id="{{$district}}" size="{{$displayParams.size|default:30}}" {{if !empty($vardef.len)}}maxlength='{{$vardef.len}}'{{/if}} value='{$fields.{{$district}}.value}'  {{if !empty($tabindex)}} tabindex="{{$tabindex}}" {{/if}}>
</td>
</tr>

26º - Save and close the file

27º - Change the file “DetailView.tpl”
28º - Search for the line with the content

<input type="hidden" class="sugar_field" id="{{$displayParams.key}}_address_street" value="{$fields.{{$displayParams.key}}_address_street.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}">

29º - Below it, place the following code

<input type="hidden" class="sugar_field" id="{{$displayParams.key}}_address_district" value="{$fields.{{$displayParams.key}}_address_district.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}">

30º - Search for the line with the content

{$fields.{{$displayParams.key}}_address_city.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}

31º - Below it, place the following code

{$fields.{{$displayParams.key}}_address_district.value|escape:'htmlentitydecode'|escape:'html'|url2html|nl2br}

32º - Save and close the file

33º - Change the file “SugarFieldAddress.js”
34º - Search for the line with the content

SUGAR.AddressField.prototype={elems:[

35º - And Add in the array

,"address_district"

36º - Save and close the file
37º - Afterwards to an Admin -> Repair -> Quick Repair and Rebuild
38º - If you wish the sabe field to shipping adress repeat the operation changind billing to shipping

Be Happy :slight_smile:

1 Like

Thank you very much for your guidance and I will follow step by step and update you accordingly.

I have another issue that I need to solve if you don’t mind; I need to reassign accounts to my users by postcode, is there a way that I can filtered by range of postcode and then assign to user by batch accordingly?

Thanks a lot and you are helpful.

I am still novice in suiteCrm so do not know if I can help you perfectly on that question.
But I think you could do the following.
1º - Go to Admin-> Studio
2º - Click on “Accounts”
3º - Click on “Layouts”
4º - Click on “Listview”
5º - Select the Shipping or Billing postal code field and drop in the Default
6º - Click in Save&Deploy
7º - Go To Accounts now you see the Field Postal Code in the Grid
8º - Click in Filter locate the Postal Code Field and put your initial post code - Here in Brazil it’s something like this 29167
9º - Click in search
10º - Now the grid only show the postal code with 29167
11º - click on Select All
12º - Mass update and make your updates there

If this help you, Be Happy :slight_smile:

Hi, I actually did that but the filtering is only limited to one postcode, I am thinking if we can filter by range, such as from 56000 to 66000 or 56 - 66 (first 2 digit of the postcode).

I think it is not yet possible to perform interval searches on fields of type Text :frowning: .

But if you have many clients, I can try to do a workaround for you, it’s not very elegant, but I think it might work.
What database do you use?

PS: Just remember, I’m not an expert on SuiteCrm. So it might be that someone has some better solution

Hi, I have followed the steps to add District to the Account module but I observed the following, I have repeated the steps for few times.

  1. I cannot manage to change the Display Label name from Billing Address District to District from Studio, the name can be saved but the name will not be changed, for me to do the name change I have to change the name from “en_us.billing_address_district.php”.
  2. On the create account page, the name showing is “LBL_ADDRESS_DISTRICT:” instead of “Billing Address District:” for both Billing Address and Shipping address, even thoiugh the name fhas been changed from the “en_us.billing_address_district.php” (picture attached)
  3. “Copy address from left” cannot copy when using Chrome but can copy by using Firefox and Edge.
  4. The District doesn’t show on the Detail Page" both in the billing and shipping address.
  5. When export the newlt created “District” is not included in the export list.
  6. Just for yur information, I didn’t made any additional district for the shipping address, it just show after I updated the billing.

Is anyting else I can make the name change to the create account page, showin the District on the detailed page and include the District in the export list?

About the reassigned by postal code range, we have few hundred contacts need to be done, I am using MySQL database. If nothing can be done, the last resource is to export the list to make the necessary chages and import again. but that is a real time consuming task to be done, I think this has to be include in SuiteCRM since it is already a great CRM software among all.

Appreciate your help… :slight_smile:

To correct:

The “District” is included in the export list, just didn’t noticed that it is far away from the usual address column at the end.

let’s go then
About the address.
Did you take the same steps to the shiping district?
If not, you need to perform the steps
1st, 2nd, 3rd, 4th (of course, switching from billing to shipping), 5th (of course, switching from billing to shipping), 6th, 7th, 8th, 9th (of course, switching from billing to shipping), 10th Of billing to shipping), 11th, 12th. I think that’s enough.

On the part of the label address, I will install a homologation environment here to try to help you, unfortunately I will not be able to do it in a fast way, but I promise I will do it as soon as possible. :slight_smile:

About part of zip code, we think we can do the following

1º - Go to Studio -> Select Accounts -> Fields
2º - Add Field
3º - Data Type (Integer), Field Name (rangepostalcode), Max Size (9), Check (Enable Range Search), Check (Disable Format)
4º - Save (The system will create a field with name rangepostalcode_c)
:whistle: [color=#880088]Now come the not elegant part[/color] :whistle:
6º - Go To Php my Admin or other admin database you use and execute the following command
:angry: [color=#0000bb]NOTE: THE COMMAND BELOW WILL ONLY WORK IF THE FIRST 3 DIGITS OF YOUR POSTAL CODE ARE INTEGER[/color] :angry:

update accounts_cstm set
accounts_cstm.rangepostalcode_c = (SELECT 
									SUBSTR (accounts.billing_address_postalcode,1,3)  
									from accounts
                                    where accounts_cstm.id_c = accounts.id)

7º - Now, Go to Studio -> Select Accounts -> Layout -> ListView
8º - In Hidden Drag de rangepostalcode and Drop in Default
9º - Click in Save & Deploy
10 - Select Accounts -> -> Layouts -> Filter -> Quick Filter
11º - In Hidden Drag de rangepostalcode and Drop in Default
12º - Click in Save & Deploy
13º - Now, Go to Account and you will see the rangepostalcode field in grid
14º - Click in Filter and in rangepostal code select Is Between
15º - Search Make your changes

After make your bulk changes.
16º - Go to Studio -> Select Accounts -> Fields
17º - Click rangepostalcode field
18º - Click in DELETE
19 - Go To Account click in filter and after search (Your Accounts will appears again)

Be Happy :wink:

Hi, great to hear from you.I have followed your steps for the billing and shipping district for Account and Contact mocules, everything is fine, but the “District” copy from left is still not workng in Chrome for Account and Contact modules, Firefox can copy but cannot pass the "District to the Detall View. I wonder what happen, I have checked many times.

For the name, I made oe changes from EditView.tpl, from {sugar_translate label=‘LBL_ADDRESS_DISTRICT’ module=’{{$module}}’}: to {sugar_translate label=‘District’ module=’{{$module}}’}: and it works fine.

For me to make changes to Contact module, I change the name from bto primary_address_street - LBL_PRIMARY_ADDRESS_STREET and
alt_address_street - LBL_ALT_ADDRESS_STREET.

No so sure what I can do now for this.

I will try the way you show for the filtering.

Thanks again.

The District is working perfectly with Edge and Firefox, Chrome is not working with the newly added “District” field, I think this is due to chrome.

I must say thank you again for your patience and help.

Thanks a lot.

Just to update you that all browsers are 100% perfect now, it is the cache issue, after clearing it, perfect. Thanks

:wink:
About postal code filter ?

1 Like

Hi, I have successfully updated the District to Account and Contact modules, how can I add this into the filter as I can’t filtered by District now.

Hi, any question I have gotten after adding the District to the address, the Geocode now is not working better than before adding the district and I suspect it is due to the arrangement of the address, may I know how to rearrange the the address sequence for cache the address?