-
Notifications
You must be signed in to change notification settings - Fork 6
Chapter 3: Configuring Custom Objects
Expanding Address Verification to Custom Areas
n this section you will learn to configure custom objects built within Salesforce CRM or any edition on the Salesforce platform. As with the steps for Standard Objects, we need to switch to the “Setup” area.
The following fields must be created for each object where you want to verify an address. If there is more than one address to verify, then one of these fields must be created for each address.
| Sample Field Name | Field Type | Field Description |
|---|---|---|
| Street | Text(255) | Will typically already be created |
| City | Text(128) | Will typically already be created |
| State | Text(20) | Will typically already be created |
| Zip Code | Text(20) | Will typically already be created |
| Country | Text(64) | Will typically already be created |
| Address Verified | Checkbox | Used to determine if the address needs to be verified |
| Address Last Verified | Date/Time | Used to determine the last time the address was verified |
| Address Return Code | Text(40) | Used for a return value from the address verification. Return values are: Confirmed, Not Confirmed, Confirmed - By Dropping Secondary Info, Confirmed - Missing Secondary Info, or Not Submitted |
Several other fields are not required, but recommended to be created for each address to be verified.
| Sample Field Name | Field Type | Field Description |
|---|---|---|
| Street 2 | Text(128) | Sometimes used to include the second line of the address. If this is not present, then the second line of the address can be included in the “Street” field. |
| Address Status | Formula (Text) | Use the following formula (substituting XXX with the API name of the "address return code" field name): If ( XXX = "Confirmed", IMAGE("/img/msg_icons/confirm16.png", "Confirmed" ,16,16) & " Confirmed", If ( XXX = "Confirmed - By Dropping Secondary Info", IMAGE("/img/msg_icons/warning16.png", "Confirmed - By Dropping Secondary Info" ,16,16) & " Confirmed - By Dropping Secondary Info", If ( XXX = "Confirmed - Missing Secondary Info", IMAGE("/img/msg_icons/warning16.png", "Confirmed - Missing Secondary Info" ,16,16) & " Confirmed - Missing SecondaryInfo",If ( XXX = "Not Submitted", IMAGE("/img/msg_icons/error16.png", "Not Submitted" ,16,16) & " Not Submitted",If ( XXX = "Not Confirmed", IMAGE("/img/msg_icons/error16.png", "Not Confirmed" ,16,16) & " Not Confirmed", IMAGE("/img/msg_icons/info16.png", "Note Yet Verified" ,16,16) & " Not Yet Verified" ) ) ) ) ) |
| Address Barcode | Text(32) | Shows the barcode returned on verification |
| Address Barcode Image | Formula (Text) | Use the following formula (substituting XXX with the API name of the "address barcode" field name): if ( not ( isblank ( XXX ) ), IMAGE("https://www.barcodesinc.com/generator/image.php?code=" + XXX + "&style=196&type=C128B&width=206&height=50&xres=1&font=3", "Address Barcode" ), "" ) |
| Address County | Text(64) | Shows the county name returned on verification |
| Address County FIPs Code | Text(32) | Shows the FIPs code for the county returned on verification |
| Address Latitude | Number (13, 5) | Used for geocoding the Latitude of the address |
| Address Longitude | Number (13, 5) | Used for geocoding the longitude of the address. |
| Address Unit | Text(64) | Shows the Apartment, Suite or Unit included in the address on verification |
| Urbanization | Text(64) | Shows the urbanization information (for Puerto Rico) returned on address verification |
| Active? | Checkbox | Shows if the Post Office thinks this is an active address |
| Carrier Route | Text(4) | Post Office carrier route code |
| Congressional District | Text(2) | Code for the Congressional District in which the address is located. |
| Daylight Savings? | Checkbox | Shows if the address is in an area that uses daylight savings time. |
| Sample Field Name | Field Type | Field Description |
|---|---|---|
| Do Not Verify | Checkbox | Use this field to indicate that you do not want the address to be verified in the future. Used mostly for automated processes. |
| Footnotes | Long Text Area | Notes on the details of the verification |
| RDI | Text(32) | Shows the Residential Delivery Indicator from the Post Office. |
| Record Type | Text(1) | Shows the returned accuracy of the verification. |
| Record Type Description | Formula (Text) | If(Record_Type__c = "F", "Firm", If(Record_Type__c = "G", "General Delivery",If(Record_Type__c = "H", "High-Rise", If(Record_Type__c = "P", "P.O. Box", If(Record_Type__c = "R", "RuralRoute", If(Record_Type__c = "S", "Street", "" ) ) ) ) ) ) |
| Time Zone | Text(48) | Shows the name of the time zone in which the address is located. |
| Vacant? | Checkbox | Shows if the Post Office believes this address to be vacant. |
| Clean Street | Text(255) | Used to copy a “clean” version of the street field. This is used in the feature that tries to auto-update previously verified addresses. |
| Verification Used | Picklist | Choices are: SmartyStreets, Google Maps, UPS |
| UTC Offset | Number (16,2) | Used to indicate how many hours different from GMT/UTC time |
| Current Time | Formula (Text) | For the code for this field, please see code on the next page. Note that you will need to set up the UTC Offset and the Daylight Savings? fields as described above. |
| Non-SmartyStreets Data | ||
| These fields are populated by sources outside of SmartyStreets and are not guaranteed to be 100% accurate. If these fields are critical for you, please contact us at support@toafinish.com to discuss sources and how often they are updated. | ||
| Island | Text (200) | This is for the name of the Island on which an address is located. Only the Hawaiian and both sets of Spanish islands are supported. |
| Area Codes | Text(32) | Phone area codes supported in this zip code |
| Urban Area Code | Text (10) | Code for the primary Urban Area for the zip code, sourced from the 2010 Census. |
| Urban Area Name | Text (255) | Primary Urban Area Name/Description for the Urban Area Code for the zip code. Must be used together with the Urban Area Code, as it is populated from the code. |
To use this formula, please replace “HOUROFFSET” with the API name of the field containing the numeric offset from UTC official time, and “DAYLIGHTSAVINGS” with the checkbox field containing a TRUE or FALSE value for daylight savings. This formula will only work for time in the US.
IF(ISBLANK(HOUROFFSET), "",
IF (AND( DAYLIGHTSAVINGS,
TODAY() >=
CASE(MOD(DATE(YEAR(TODAY()),3,8) - DATE(1900,1,7),7),
0, DATE(YEAR(TODAY()),3,8),
1, DATE(YEAR(TODAY()),3,8)+6,
2, DATE(YEAR(TODAY()),3,8)+5,
3, DATE(YEAR(TODAY()),3,8)+4,
4, DATE(YEAR(TODAY()),3,8)+3,
5, DATE(YEAR(TODAY()),3,8)+2,
DATE(YEAR(TODAY()),3,8)+1),
TODAY() <
CASE(MOD(DATE(YEAR(TODAY()),11,1) - DATE(1900,1,7),7),
0, DATE(YEAR(TODAY()),11,1),
1, DATE(YEAR(TODAY()),11,1)+6,
2, DATE(YEAR(TODAY()),11,1)+5,
3, DATE(YEAR(TODAY()),11,1)+4,
4, DATE(YEAR(TODAY()),11,1)+3,
5, DATE(YEAR(TODAY()),11,1)+2,
DATE(YEAR(TODAY()),11,1)+1)),
/* CALCULATE FOR IT BEING CURRENTLY DST */
MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 6, 2 ) & "/" &
MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 9, 2 ) & "/" &
LEFT( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 4 ) & " " &
TEXT(
IF(
OR(
VALUE( MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 12, 2 ) ) = 0,
VALUE( MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 12, 2 ) ) = 12), 12,
VALUE( MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 12, 2 ) ) -
IF( VALUE( MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 12, 2 ) ) < 12, 0, 12 )
)
)
&":"& MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 15, 2 ) &" "&
IF( VALUE( MID( TEXT( NOW()+ (HOUROFFSET +1) /24 ), 12, 2 ) ) < 12, "AM", "PM"
),
/* CALCULATE FOR IT NOT BEING CURRENTLY DST */
MID( TEXT( NOW()+ HOUROFFSET /24 ), 6, 2 ) & "/" &
MID( TEXT( NOW()+ HOUROFFSET /24 ), 9, 2 ) & "/" &
LEFT( TEXT( NOW()+ HOUROFFSET /24 ), 4 ) & " " &
TEXT(
IF(
OR(
VALUE( MID( TEXT( NOW()+ HOUROFFSET /24 ), 12, 2 ) ) = 0,
VALUE( MID( TEXT( NOW()+ HOUROFFSET /24 ), 12, 2 ) ) = 12), 12,
VALUE( MID( TEXT( NOW()+ HOUROFFSET /24 ), 12, 2 ) ) -
IF( VALUE( MID( TEXT( NOW()+ HOUROFFSET /24 ), 12, 2 ) ) < 12, 0, 12 )
)
)
&":"& MID( TEXT( NOW()+ HOUROFFSET /24 ), 15, 2 ) &" "&
IF( VALUE( MID( TEXT( NOW()+ HOUROFFSET /24 ), 12, 2 ) ) < 12, "AM", "PM"
)
)
)If you are going to be verifying international addresses, there are a few fields you should create if you want to have helpful data.
| Sample Field Name | Field Type | Field Description |
|---|---|---|
| Address Precision | Text (255) | How precise is the address? From best to worst: ,DeliveryPoint — rooftop level,Premise ,property or building level,Thoroughfare — street level,Locality — city or town level,AdministrativeArea — state or province level,None — unknown address |
| Administrative Area | Text (255) | The most common administrative division within a country (e.g. Region) |
| Geocode Precision | Text (255) | How precise is the geocoding of the address? From best to worst: ,DeliveryPoint — rooftop level,Premise — property or building level,Thoroughfare — street level,Locality — city or town level |
| AdministrativeArea — state or province level,None — unknown address | ||
| Organization | Text (255) | The name of the recipient, firm, or company at this address |
| Premise | Text (64) | Alphanumeric code pertaining to an individual location |
| Premise Extra | Text (64) | Extra information about the premise that is not necessarily authoritative but might still be useful |
| Sub Building Number | Text (64) | The alphanumeric component of the sub_building |
| Sub Building Type | Text (64) | The leading sub-building type of the sub_building |
| Super Administrative Area | Text (255) | The largest administrative division within a country |
| Thoroughfare Name | Text (255) | The name component of the thoroughfare |
Every custom address to be verified must first be set up in the configuration page. Once in the setup page, click the “Manage Addresses” tab and then click the “New Address” button.
Enter a name for the new address, which begins with the object name. Next, select the object, make the address Active, and then fill in at least the Required Fields and press the “Save” button. This will add the current address as a valid address to verify in your org.

- Note: If you want to add an address from an object that does not show up in the Object dropdown, you will need to first add this object using the Add Supported Object button on the prior page.
Please note that the following section will be very technical and perhaps difficult to follow if you do not yet have experience in Salesforce development. We provide code samples, but they must be tweaked and modified to fit your own custom object.
| GitHub.com Address Verification Sample Code Repository |
|---|
| https://github.com/ToAFinish/addressverification |
All of the JavaScript code referenced in the pages below can be found in the "lightning" folder in our GitHub repository:
- Go to Setup -> Custom Code -> Apex Classes and press the "New" button.
- Note: this must be done in a sandbox or dev org
- In a new tab, go to our GitHub repository, in the Lightning folder, and open the "custom_apex_controller" entry. Paste the code (not the line numbers) into the box in Salesforce. You will need to replace all of the references to the custom Office__c object with the object and field names of your custom object. Once this is done, Save. If it saves, then you are most likely safe to continue.
-
Now open the Developer Console
-
Click File -> New -> Lightning Component
-
Give the component a name and optional description. Click Submit.
-
Replace the default text in the new component with the code in the "custom_lightning_component" entry in our GitHub repository.
-
Now click on the Controller item to create a new controller for this bundle.
-
Replace the default text in the new controller with the code in the "custom_lightning_controller" entry in the Lightning folder in our GitHub repository. Again, updating the areas referencing the sample Office__c custom object with your own custom object and fields.
- Note: To ensure that you have located all areas in the code that need attention, do a search for "__c", which indicates a custom object or field. Replace the name of the field in the code with the name in your custom object.

-
Go back to Setup -> Object Manager -> Creates -> Custom Object .
-
Scroll down to the "Buttons, Links, and Actions" section and click on the "New Action" button.
-
Select "Lightning Component" as the Action Type, and then select the component that you just created. Give it a name like "Verify Address" and save.
-
Now edit the Page Layout for your custom object. If you have multiple layouts, you will need to do this several times. Go to the " Salesforce Mobile and Lightning Experience Actions " menu at the top and find the Action you just created. Drag it down into the "Salesforce 1 and Lightning Actions" section.
- Note: if the "Salesforce Mobile and Lightning Experience Actions" section is closed, you might need to open it for updates.
- Now switch to Lightning and you can test the button. You can also test it on Salesforce Mobile.
A custom button must be created on the object to launch the address verification, and then added to the layout.


