Announcement

As of April 17, 2018, this site is now in read-only mode. To start new Blackbaud Developer’s discussions, you will find Developer Discussions in the Blackbaud CRM Community.

To post or respond to Blackbaud Community discussions, you will have to login using a www.blackbaud.com login. Learn how to login here. If you have questions or need assistance, please email community@blackbaud.com.

Adding Address Validation to a custom form

By: christi

Posted on: March 29, 2016

NOTE: You need to have Address Validation turned on before beginning. To see if Address Validation is enabled, open the Address Add Form 2, set the country to a country with Address Validation enabled, and ensure that the Validate button shows.

At a minimum, your data form must have the following fields (though they can be named differently and can be hidden, they do need to exist in your form): COUNTRYID, ADDRESSBLOCK, CITY, STATEID, POSTCODE.

In your form, add the UIAction that will trigger the validation:


<UIAction ActionID="VALIDATEADDRESSACTION" Caption="Validate" Description="Perform validation on the address" >
	<ShowCustomForm>
		<ModelComponent AssemblyName="Blackbaud.AppFx.Address.UIModel.dll" ClassName="Blackbaud.AppFx.Address.UIModel.ValidateAddressFormUIModel" />
	</ShowCustomForm>
</UIAction>

If desired, add a FormField to exclude this address from validation. Setting this value will exclude this address from the Address Validation Process. This is a parameter to USP_ADDRESS_ADD and USP_ADDRESS_CREATE, if you utilize those procedures. If not, the value is stored in ADDRESSVALIDATIONUPDATE.


create procedure dbo.USR_USP_DATAFORMTEMPLATE_MYCUSTOMFORM
(
	@ID uniqueidentifier = null output,
	@CONSTITUENTID uniqueidentifier,
	@CHANGEAGENTID uniqueidentifier = null,
	@ADDRESSBLOCK nvarchar(150) = '',
	@CITY nvarchar(50) = '',
	@COUNTRYID uniqueidentifier = null,
	@STATEID uniqueidentifier = null,
	@POSTCODE nvarchar(12) = '',
	@OMITFROMVALIDATION bit = 0
)


<FormField FieldID="OMITFROMVALIDATION" Caption="Omit this address from validation" />

In your UIModel project, add a reference to Blackbaud.AppFx.Address.UIModel and import it into the UIModel for your form.

In your UIModel Loaded handler, add the following code:


Dim options = New AddressFieldHandlerOptions(Me.COUNTRYID, Me.ADDRESSBLOCK, Me.CITY, Me.STATEID, Me.POSTCODE)
options.OmitFromValidation = Me.OMITFROMVALIDATION
options.ValidateAddressAction = Me.VALIDATEADDRESSACTION
AddressFieldsHandler.HandleFields(options)

Address Validation

NOTE: The validate action will not appear until the COUNTRYID field has been populated with a country that supports Address Validation.

One thought on “Adding Address Validation to a custom form

  1. I have created a business process that is running address validation against addresses in a custom table. I was wondering if you have done anything like this and if you have been able to overcome the performance issues with looping through each row and calling ValidateSingleAddress. It takes us about a second per call, which takes a very long time when you are running it against 50K records. Below is a code snippet:

    Dim req As New ValidateSingleAddressRequest
    req.AddressBlock = CheckDBNullString(oDataRow(“ADDRESSBLOCK”))
    req.City = CheckDBNullString(oDataRow(“CITY”))
    req.PostCode = CheckDBNullString(oDataRow(“POSTCODE”))

    Dim gStateID As Guid
    If Guid.TryParse(CheckDBNullString(oDataRow(“STATEID”)), gStateID) = True Then
    req.StateID = gStateID
    End If

    Dim gCountryID As Guid
    If Guid.TryParse(CheckDBNullString(oDataRow(“COUNTRYID”)), gCountryID) = True Then
    req.CountryID = gCountryID
    Else
    req.CountryID = New Guid(“98B66227-C473-43F9-9445-218620DCF2A5”)
    End If

    Dim reply As ValidateSingleAddressReply = Blackbaud.AppFx.AddressValidation.Server.ServiceMethods.ValidateSingleAddress(req, RequestContext, True)

Leave a Reply

Privacy Policy | Sitemap | © 2011 Blackbaud, Inc. All Rights Reserved

Digital Ocean