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.

Leave a Reply

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

Digital Ocean