Address Attribute

The Address attribute stores a reference to a user-entered address. Introduced in 10.6.0.

 

Overview

The Address attribute collects a user-entered address as a single data field, eliminating the need to configure multiple, independent fields for street/city/state/etc. 

In addition, if the Address Verification system is enabled, user-entered addresses are geocoded (converted into lat/long GPS coordinates) and parsed into constituent elements (city/state/etc) and stored in the ADDRESS table.

Configuration

The only configuration option for this attribute is a JSON object containing properties that are passed through to the autocomplete UI in input mode. For more information on the available settings, see https://smartystreets.com/docs/cloud/us-autocomplete-pro-api

Advanced Options (AutoComplete)
{ "max_results": null, "include_only_cities": null, "include_only_states": null, "include_only_zip_codes": null, "exclude_states": null, "prefer_cities": null, "prefer_states": null, "prefer_zip_codes": null, "prefer_ratio": null, "prefer_geolocation": null }

Input Mode

In input mode, the address is collected using a single text input field that performs address completion using the Smarty Streets service

If address verification is disabled, then a single text input field is displayed without autocomplete. Addresses can still be collected without the verification service, but they will not be geocoded, parsed into constituent pieces, etc.

Display Mode

In display mode, the address is displayed as readonly text.

Data Storage

This attribute stores ADDRESS_ID from the ADDRESS table

Address Attribute Fields

  • AddressId (Integer)

  • OwnerMemberId (Integer)

  • Label (String)

  • FullAddress (String)

  • StreetLine1 (String)

  • StreetLine2 (String)

  • StreetLine3 (String)

  • City (String)

  • State (String)

  • Province (String)

  • ZipCode (String)

  • Country (String)

  • ValidationStatus (AddressValidationStatusEnum: Unvalidated, Failed, Validated, Errored)

  • ValidatedOn (DateTime)

  • ValidationResultJson (String)

  • GpsLatitude (float)

  • GpsLongitude (float)

  • CreatedByProcess (AddressCreatedByProcessEnum: Workflow, Profile)

  • CreatedOn (DateTime)

  • ModifiedOn (DateTime)

Advanced use cases

These advanced use cases require that the Address Verification feature be enabled. These techniques will not work on an address that is not geocoded/parsed by the validator at the time of data entry.

Calculating the distance between two addresses in a Template

Template attributes can calculate the distance between two addresses using the GetDistanceTo() method. 

Note that this calculates "straight-line" distance between two points; it does not calculate driving or travel distance.

Distance Template
@using Heuristics.LearningBuilder.WorkflowAttributes @DistanceFrom() @functions { public string DistanceFrom() { try { var address1 = Model.MemberRole.GetAttribute<AddressAttribute>("EXT_ROLE_Address_1"); var address2 = Model.MemberRole.GetAttribute<AddressAttribute>("EXT_ROLE_Address_2"); if (address1 == null || address2 == null || address1.AddressId == 0 || address2.AddressId == 0) { return string.Empty; } return address1.GetDistanceTo(address2, DistanceUnit.Kilometers).ToString("N2") + " kilometers"; } catch(Exception a) { return a.Message; } } }

Extracting the address elements from an Address attribute

Component Template
@using Heuristics.LearningBuilder.WorkflowAttributes @using Heuristics.LearningBuilder.Web.Helpers @using System.Web.Mvc @using System.Web @using Heuristics.Library.Extensions @Raw(DisplayAddressComponents()) @functions { public string DisplayAddressComponents() { try { var address = Model.MemberRole.GetAttribute<AddressAttribute>("EXT_ROLE_Address_1"); if (address == null || address.AddressId == 0) { return string.Empty; } var output = new MvcHtmlString("<ul></ul>"); return output .Append("<li>AddressId: " + address.AddressId.ToString() + "</li>") .Append("<li>OwnerMemberId: " + address.OwnerMemberId.ToString() + "</li>") .Append("<li>Label: " + address.Label + "</li>") .Append("<li>Full Address: " + address.FullAddress.ToString() + "</li>") .Append("<li>Validation Status: " + address.ValidationStatus.ToDescription() + "</li>") .Append("<li>Created By Process: " + address.CreatedByProcess.ToDescription() + "</li>") .Append("<li>Created On: " + address.CreatedOn.ToString() + "</li>") .Append("<li>Modified On: " + address.ModifiedOn.ToString() + "</li>") .Append("<li>Latitude: " + (address.GpsLatitude.HasValue ? address.GpsLatitude.Value.ToString() : string.Empty) + "</li>", address.GpsLatitude.HasValue) .Append("<li>Longitude: " + (address.GpsLongitude.HasValue ? address.GpsLongitude.Value.ToString() : string.Empty) + "</li>", address.GpsLongitude.HasValue) .ToHtmlString(); } catch(Exception a) { return a.Message; } } }

 

Sample Use Cases
  • Collecting a user-entered address as a single element, instead of a collection of multiple street/city/state attributes.

  • Displaying the distance between two addresses

Business Rules
  • The user-entered address is only geocoded and parsed into its constituent elements if the EnableAddressVerification app config setting is enabled at the time that the address is entered.

  • Enabling address verification after address data is collected will not cause the pre-existing addresses to be validated/parsed.



Filter by label

There are no items with the selected labels at this time.