Introduction

AFD Engine API makes using address management and bank validation in .NET easy, minimising your work to get an integration up and running quickly, while also providing full flexibility to customise it to your requirements. Regardless of if you are using it with a Windows Form, ASP .NET or a backend application our .NET class library makes integration with your application simple.

If you wish to integrate directly into a WinForms application, please see information about WinForms below.

Setup

To use AFD Engine API you first need to install an AFD product (Windows only) or have access to an Evolution server. You can download the API here.

To use AFD Engine API in .NET simply add a Reference to your project to our class library (AFD.API.dll). To do this right click the References item under your project in Solution Explorer select “Add Reference”, and use the Browse Tab to browse to the library file.

Integrating into any .NET Application

Engine API can be easily used in any .NET application including ASP .NET applications, WPF/Silverlight, backends etc. and you can determine if and how to display results on any interface you provide.

Creating an Instance of the Engine Class

Add the following line to the top of your form’s .cs file to reference the AFD.API:

				
					using AFD.API;
				
			

To create an instance of the Engine class add the following line to your code:

				
					Engine engine = new Engine(EngineType.Address);
				
			

(You can also use EngineType.Bank or EngineType.Email if wanting to carry out Bank or Email Validation). If you wish to mix Address, Bank and/or Email validation simply create multiple instances of the Engine class.

If using an evolution server rather than a locally installed product set the Authentication property to an instance of the Authentication class for your server, e.g.:

				
					engine.Authentication = new Authentication("http://myserver:81", "333333", "password");
				
			

Task Reference for Engine Class

Address Lookup (Postcode and Fast-Find)

To find an address record from the postcode or any fragment of the address use the Find method on an instance of the Engine class with the lookup string you wish to use and one of the following operations:

  • Operation.FastFindLookup – Looks up the supplied string which can be a postcode or any fragment of the address.
  • Operation.PostcodeLookup – Looks up a supplied postcode
  • Operation.PostcodePropertyLookup – Looks up a supplied postcode which optionally may also include a property, e.g. “279, B11 1AA”

This will return:

  • > 0 The number of results found
  • < 0 No results have been found (-2) or an error has occurred (use LastErrorText to obtain a human readable message for the error).

You can then iterate through the engine.Records collection to process each result in your application. This collection has the method getField(string) which you can use to return any of the fields for the result.

For example:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Address);
    // Lookup the records
    int results = engine.Find("b11 1aa", Operation.FastFindLookup);
    // Check for error
    if (results < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Iterate through results
    foreach (AFD.API.Record record in engine.Records) {
        // Obtain the fields you require – some examples:
        string list = record.GetField("List");
        string organisation = record.GetField("Organisation");
        string property = record.GetField("Property");
        string street = record.GetField("Street");
        string locality = record.GetField("Locality");
        string town = record.GetField("Town");
        string postcode = record.GetField("Postcode");
        // display a string for the result
        // - replace with a function to process the result in your application?
        MessageBox.Show(list);
    }
				
			

The number of results returned for FastFind operations will be limited by the MaxRecords Property of the Engine class instance. When using installed data, it may also be limited by the Timeout Property. For evolution, the server’s pre-configured MaxSearchTime may be a limiting factor.

To carry out a search for an Address:

  • Call clear to Clear any current address fields.
  • Use the setField method to set the value of each field you wish to search
  • Call Find with Operation.Search (the Lookup parameter will be ignored)

The Find function will return:

  • > 0 The number of results found
  • < 0 No results have been found (-2) or an error has occurred (use LastErrorText to obtain a human readable message for the error).

You can then iterate through the engine.Records collection to process each result in your application. This collection has the method getField(string) which you can use to return any of the fields for the result.

For example:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Address);
    // Set the fields to Search
    engine.Clear();
    engine.SetField("street", "Commercial Street");
    engine.SetField("town", "Birmingham");
    // Search for the records
    int results = engine.Find(null, Operation.Search);
    // Check for error
    if (results < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Iterate through results
    foreach (AFD.API.Record record in engine.Records) {
        // Obtain the fields you require – some examples:
        string list = record.GetField("List");
        string organisation = record.GetField("Organisation");
        string property = record.GetField("Property");
        string street = record.GetField("Street");
        string locality = record.GetField("Locality");
        string town = record.GetField("Town");
        string postcode = record.GetField("Postcode");
        // display a string for the result
        // - replace with a function to process the result in your application?
        MessageBox.Show(list);
    }
				
			

The number of results returned for Search operations will be limited by the MaxRecords Property of the Engine class instance. When using installed data it may also be limited by the Timeout Property. For evolution the server’s pre-configured MaxSearchTime may be a limiting factor.

Bank records can be looked up or searched for in exactly the same way as Address records. The difference being that the Engine class must be instantiated with a parameter of EngineType.Bank rather than EngineType.Address.

The applicable operations are:

  • Operation.FastFindLookup – Looks up the supplied string which can be a sortcode, bank/branch name, location, STD Code or BIC.
  • Operation.Search – Search for results matching the search fields specified using the SetField method.

An example of a Bank Lookup:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Bank);
    // Lookup the records
    int results = engine.Find("560036", Operation.FastFindLookup);
    // Check for error
    if (results < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Iterate through results
    foreach (AFD.API.Record record in engine.Records) {
        // Obtain the fields you require – some examples:
        string list = record.GetField("List");
        string sortcode = record.GetField("SortCode");
        string ownerBankFullName = record.GetField("OwnerBankFullName");
        string branchTitle = record.GetField("FullBranchTitle");
        string location = record.GetField("Location");
        string directDebits = record.GetField("BACSDirectDebits");
        // display a string for the result
        // - replace with a function to process the result in your application?
        MessageBox.Show(list);
    }
				
			

Bank Account Validation

To validate an account number use the setField method to set the value of the sort code and account number (alternatively the IBAN can be used)

You may also wish to set the clearing system if you want to restrict validation to the UK (BACS), or Irish (IPSO) systems only.

Call Find with Operation.ValidateAccount (the Lookup parameter will be ignored)

Following successful validation a single record will be returned. It is recommended you use the sortcode and account number returned rather than that you supplied as non-standard length account numbers will be transcribed for you.

An example of a Bank Account Validation:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Bank);
    // Set the Account Details to validate
    engine.Clear();
    engine.SetField("SortCode", "774814");
    engine.SetField("AccountNumber", "24782346");
    // RollNumber can also be set if applicable, IBAN can also be validated instead
    // Validate the Account Details
    int results = engine.Find(null, Operation.AccountValidate);
    // Check for error, e.g. invalid account number
    if (results < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Success will return a single result
    string sortcode = engine.GetField("SortCode");
    string accountNumber = engine.GetField("AccountNumber");
    string iban = engine.GetField("IBAN");
    string rollNumber = engine.GetField("RollNumber");
    string typeOfAccount = engine.GetField("TypeOfAccount");
    string clearingSystem = engine.GetField("ClearingSystem");
    MessageBox.Show(“Account Number is Valid");
				
			

Card Number Validation

To validate a debit or credit card number use the setField method to set the value of the card number and optionally expiry date. (The expiry date is checked that it is in range for the current date if provided).

Call Find with Operation.ValidateCard (the Lookup parameter will be ignored).

Following successful validation a single record will be returned.

An example of Card Number Validation:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Bank);
    // Set the field to Validate
    engine.Clear();
    engine.SetField("cardnumber", "4694782385016585");
    engine.SetField("expirydate", "10/17"); // This field is optional
    // Validate the Card Details
    int results = engine.Find(null, Operation.CardValidate);
    // Check for error, e.g. invalid account number
    if (results < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Success will return a single result
    string cardType = engine.GetField("CardType");
    MessageBox.Show(“Valid: “ + cardType);
				
			

Email Validation

To validate an email address from an instance of the Engine class instantiated with EngineType.Email simply call the Find method with the email address to validate and Operation.EmailValidate.

An example of Email Address Validation:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Email);
    // Validate the Email
    int results = engine.Find("support@afd.co.uk", Operation.EmailValidate);
    // Check for error, e.g. invalid Email Address
    if (results < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Email Address is Valid
    MessageBox.Show("Email Address is Valid");
				
			

Statelessly Retrieving Previous Records

If you have returned results following an address or bank lookup or search and require to fetch one of those results again you can do this with a Retrieve operation. An example when you might wish to do this if is returning a list of results to the user, wanting to minimise data passed and then need to retrieve the full record when a user selects an individual record.

To do this you need to store the key (use getField(“Key”) to obtain this) when processing the original record.

Please note that this Key is unique in a particular dataset so can be used statelessly or across multiple servers as long as the same version of the data is still in use. It is not unique across future versions of the data and therefore should not be stored in a database as a unique reference.

To retrieve a record call Find with the key for the record specified in the lookup field and an operation of Operation.Retrieve.

A single result will be returned which you can then process.

This will return:

  • 1 The single result was found
  • < 0 No results have been found (-2) or an error has occurred (use LastErrorText to obtain a human readable message for the error).

For example:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Address);
    // Lookup the records
    int results = engine.Find("B11 1AA1001", Operation.Retrieve);
    // Check for error
    if (results < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Obtain the fields you require – some examples:
    string organisation = engine.GetField("Organisation");
    string property = engine.GetField("Property");
    string street = engine.GetField("Street");
    string locality = engine.GetField("Locality");
    string town = engine.GetField("Town");
    string postcode = engine.GetField("Postcode");
				
			

Calling off results individually

For ease of use the Find method used in the previous sections returns all results at once until a predetermined timeout or maximum record count is reached (if applicable). When used with an evolution server there is little point to doing anything else as results have to result from the same web request.

However in some cases when using an installed product, you may wish to return results one-by-one as they are called off or provide your own mechanism for determining when to abort a search (for example based on the actual results that come back).

In such scenarios rather than calling Find, you can call the FindFirst and FindNext methods. FindFirst has identical parameters to Find but rather than returning the results in the Records collection, it instead returns one result at a time (FindNext takes no parameters).

You do also need to be aware that FindFirst and/or FindNext will sometimes return a value of 0 indicating a record or sector break which is provided to give the opportunity to cancel long searches and at which point no new result will be returned.

An example of an Address Fast-Find, identical that given in section 4.2.1 but using findFirst and FindNext is as follows:

				
					// Create instance of the Engine class
    Engine engine = new Engine(EngineType.Address);
    // Lookup the records
    int result = engine.FindFirst("b11 1aa", Operation.FastFindLookup);
    // Check for Error, but note if 0 has been returned it is still possible no results will be found
    if (result < 0) {
        MessageBox.Show(engine.LastErrorText);
        return;
    }
    // Process and call off each result
    long results = 0;
    while (result >= 0) {
        if (result > 0) {
            // obtain some of the fields for the result to use in your application
            string list = engine.GetField("List");
            string organisation = engine.GetField("Organisation");
            string property = engine.GetField("Property");
            string street = engine.GetField("Street");
            string locality = engine.GetField("Locality");
            string town = engine.GetField("Town");
            string postcode = engine.GetField("Postcode");
            // display a string for the result
            // - replace with a function to process the result in your application?
            MessageBox.Show(list);
            results++;
        }
        else if (result == 0) {
            // sector or record break – take the chance to allow user to cancel?
        }
        // set your own condition(s) to abort the search
        if (results > 500) break;
            result = engine.FindNext();
        }
        if (results > 0) {
            // success
        }
        else {
            MessageBox.Show("No Results Found");
        }
    }
				
			

Function Reference for Engine Class

The following functions are available in the Engine Class:

3.3.1. Clear

				
					void Clear()
				
			

This clears the fields, necessary prior to setting criteria for a search (not necessary for fast-finds and postcode lookups).

GetField

				
					string GetField(string)
				
			

This property returns the value of the specified field name for the current record. When using Find to return multiple results at once you should use the GetField method of a Record in the Records collection property instead to retrieve fields from any record returned.

Find

				
					int Find(string Lookup, Operation, optional SkipOptions)
				
			

Carries out an operation using the AFD API. For a lookup, card or email validation the Lookup parameter specifies the lookup string (for example a postcode, sortcode, card number or email address). The Operation specifies the operation to carry out.

The following Operations are supported:

Engine TypeOperationDescription
AddressFastFindLookupLooks up an address fragement specified by the Lookup parameter. This could be a postcode or fields from an address.
 PostcodePropertyLookupLooks up an address from the specified postcode and optionally property (e.g. “277, B11 1AA”) specified by the Lookup parameter.
 PostcodeLookupLooks up an address from the specified postcode.
 SearchSearches for an address specified by criteria set by calling setField for the appropriate fields prior to calling this function (lookup parameter is ignored and can be null)
 RetrieveRetrieves a previously returned record. The required records key field should be specified as the lookup parameter.
BankFastFindLookupLooks up a sort code or searches for a bank from the fragment given as specified by the Lookup parameter.
 SearchSearches for a bank branch specified by critieria set by calling setField for the appropriate fields prior to calling this function (lookup parameter is ignored and can be null).
 RetrieveRetrieves a previously returned record. The required records key field should be specified as the lookup parameter.
 AccountValidateValidates an account number. Use setField to set both the sortcode and account number or alternatively the IBAN prior to calling this function. The lookup parameter is ignored.
 CardValidateValidates a card number. The lookup parameter should be set to the card number to validate.
 EmailValidateValidates an email address. The lookup parameter should be set to the email address to validate.

For address functions you can optionally set the SkipOptions to a member of the SkipOptions enumeration to skip records in large searches. These options are as follows:

Skip OptionDescription
NoneDefault – Returns all matching records (unless a timeout or maximum number of records is reached).
AddressOnly returns the first matching record per address (or household). Only has any effect with Names & Numbers.
PostcodeOnly returns the first matching record for each postcode.
SectorReturns the first matching record per Sector (this is the portion of the postcode prior to the space and the first digit afterwards, e.g. “B11 1”).
OutcodeReturns the first matching record per Outcode (this is the portion of the postcode prior to the space, e.g. “B11”);
TownReturns the first matching record per Royal Mail Post Town.
AreaReturns the first matching record per Postcode Area (this is the letters at the start of the postcode, e.g. “B” or “AB”).

This function returns the number of matching records returned, or a value < 0 if an error has occurred. Use the LastErrorText property to obtain a human readable version of an error.

FindFirst

				
					int FindFirst(string Lookup, AFD.API.Operation Operation)
				
			

This method is identical in parameters to Find. The difference being that it will obtain the first result only (or sometimes a record or sector break in a long search). You can then call FindNext() to obtain subsequent records.

In general it is recommended you use Find to obtain results as this simplifies calling off results and in-built support for the MaxRecords and, for installed data, Timeout properties to restrict long searches to help prevent your application becoming unresponsive. However in cases were you are using locally installed data and wish to have full control over this process this method gives you that flexibility.

Some examples were you might use this would be if you wish to return results to the user as they are called off rather than at the end of a long search, or you wish to be able to determine when to abort a search based on the results themselves or user intervention then this method gives you that flexibility.

The return codes are the same as for Find with the addition of 0 which indicates a record or sector break, when returned no result has been returned (You will need to call FindNext to continue the search). This allows the opportunity to cancel long searches after a predetermined timeout etc. if required.

FindNext

				
					int FindNext()
				
			

This method is used following a call to FindFirst to repeatedly call off subsequent records. It will return 1 on success, 0 on a record or sector break (indicating no new result has been returned but giving the opportunity to cancel or provide user responsiveness) or -6 to indicate the end of a search.

InsertRecord

				
					bool InsertRecord(int)
				
			

This function is not relevant when not using with an instance of Windows Forms and will always return false in such cases.

LastErrorText

				
					string LastErrorText()
				
			

This returns human readable text for the last error to occur (will return an empty string if the last operation was successful). While you may wish to display your own error text for some errors it is recommended that you fall-back to using this for any error code you have not handled yourself.

SetField

				
					bool SetField (string FieldName, string FieldValue)
				
			

Sets the value of the specified field for searching.

Properties Reference for Engine Class

DialogOptions and Mappings are not documented in this section as they are ignored unless Engine is instantiated for use specifically with a Windows Form (see Section 3 for futhur details).

AddressFields

Set the number of address fields to use when returning free address fields with GetField (e.g. address1, address2, etc.). The default is 6, setting this to the same number as the fields you have causes Engine to squeeze fields in as required.

IncludeOrganisation

Boolean value indicating if the Organisation is included in free address field (i.e. if you obtain address1, address2, etc.)

LastErrorText

Returns human readable descriptive text for the last operation. Returns an empty string if no error occurred (result code >= 0).

LastResult

Returns the result code for the last operation. While be < 0 if an error occurred or > 0 if successful.

MaxRecords

Sets the Maximum number of records to return from any lookup or search (default 500).

Records

Following an option calling Find this is a collection of the results (Record objects). Each Record in the collection has a getField method used to obtain individual fields for that result.

Timeout

Sets the maximum time in seconds to spend searching for records (Default is 30 seconds). This helps prevent very long searches making an application unresponsive or a very vague search taking too long when it could instead be refined. This is applicable to installed products only. For evolution the server will be preconfigured with a MaxSearchTime which has the same effect.

UpperCaseTown

Indicates that the Town will always be returned in upper case (default and preferred by Royal Mail for address labels)

Record Class

The Record class cannot be instantiated on its own. A collection of Record objects is returned by the Records Property of the Engine class following an operation calling Find`.

The class has a single method GetField. This property returns the value of the specified field name for the record.

Collections

EngineType

This collection is used on instantiating the Engine class to specify the type of Engine used. The values are Address for Address Management (e.g. Address Fastfind, Search, etc.), Bank for BankFinder (e.g. Account or Card Validation) or Email for Email Validation.

You cannot mix types in one instance of the Engine class, but you can have multiple instances of the class of different types called in the same function in your code

Operation

This collection is used to specify the operation carried out. Section 4.3.3 provides a table with the valid Operations for each EngineType.

Return Codes

The possible return codes, available as the return code from FindFirst or the LastResult property, are as follows:

Success Codes

These are the possible codes returned:

Value Description
0 The search/lookup has not completed but may take some time and so is returning to give the user the option to cancel a long search.
1 The function was successful and a matching record has been returned.
2 This applies only to Bankfinder account number validation and indicates that the function was successful and the account number should be taken as valid. However, as account numbers on this sortcode cannot be validated you may wish to double check it is correct.

Error Codes

These specify the possible errors returned from any API function:

Value Description
-1 The field specification string specified is invalid. This shouldn’t be returned under normal circumstances.
-2 No records matching your lookup or search criteria were found.
-3 The record number provided (e.g. when re-retrieving an item from a list box) is invalid.
-4 An error occurred attempting to open the AFD data files. Check they are correctly installed.
-5 An error occurred reading the data. Likely to be due to corrupt data so software may need to be re-installed.
-6 End of Search (when the last result has already been called off – indicates there are no more results to return).
-7 Indicates there is an error with the product registration. Normally due to it having expired. Run the Welcome program to re-register the software.
-8 Occurs if you attempt to search for a Name and Organisation at the same time. Also occurs with Postcode Plus if the UDPRN field is searched for at the same time as any other field.
-99 Indicates that the user clicked the cancel button if the DLL internal list box was used.
-12 The sort code specified for an account number validation does not exist.
-13 The sortcode specified for an account number validation is invalid.
-14 The account number specified for an account number validation is invalid.
-21 The sort code and account number given are for a building society account which also requires a roll number for account credits. No roll number has been supplied or is incorrect for this building society.
-22 The International Bank Account Number provided is in an invalid format
-23 The IBAN provided contains a country that is not recognised as valid
-24 Both an IBAN and Account Number was provided and these details do not match.
-15 The expiry date specified for a card validation is invalid.
-16 The card has expired
-18 The card number specified for a card validation is invalid.
-19 The card number specified is a Visa card which can be used in an ATM only.
-20 While the card number appears to be a valid one, the card is not of any of the known types and is therefore unlikely to be acceptable for payment.

Evolution Server Details

The AFD.API.Authentication Object is used to specify authentication details to use Engine with an evolution server. If you do not assign one to the Authentication property of the Engine class then a default instance is created which uses local installed product.

We strongly recommend that the details passed to create an instance of the Authentication object are stored as modifiable configuration parameters in your application, so that details can be changed in the future without needing to alter code.

There are three initialisers for the Authentication object:

  • Authentication()

This creates a version to work with installed data only. You will require a copy of an AFD product installed on each machine your software runs on. This is the fastest and most efficient method and is particularly ideal for offline use.

  • Authentication(Serial, Password)

This creates a version to work with AFD’s server. You pass it your serial number and password.

  • Authentication(Server, Serial, Password)

This creates a version to work with your own server. The Server parameter should be a string including the protocol, server and (if not 80) the port so as to give wide compatibility. For example http://server:81

ASP .NET Webpage

With ASP .NET webpages you can easily use Engine with the Engine class as described in Section 4 of this manual.

If you wish to use auto-configuration with your webpage you may wish to consider using Engine Web rather than Engine API as Engine Web uses JavaScript and AJAX to lookup addresses in-line from your webpage.

If using Engine API in an ASP .NET webpage an example of obtaining address results to add to a list box is as follows:

				
					protected void ButtonLookup_Click(object sender, EventArgs e)
        {
        // Create an instance of the Engine class for Address operations
        AFD.API.Engine engine = new AFD.API.Engine(AFD.API.EngineType.Address);
        // Lookup the postcode or fast-find string in the TextLookup TextBox
        int results = engine.Find(TextLookup.Text,
        AFD.API.Operation.FastFindLookup);
        // Add Items to ListBoxAddress For The User To Select From
        ListBoxAddress.AutoPostBack = true;
        foreach (AFD.API.Record record in engine.Records) {
            string ListText = record.GetField("list");
            string ListValue = record.GetField("key");
            ListItem item = new ListItem(ListText, ListValue);
            ListBoxAddress.Items.Add(item);
        }
    }
				
			

On selecting an item from a List Box the record can be re-looked up to provide full address details for submission, an example of this:

				
					protected void ListBoxAddress_SelectedIndexChanged(object sender, EventArgs e)
        {
        // Create an instance of the Engine class for Address operations
        AFD.API.Engine engine = new
        AFD.API.Engine(AFD.API.EngineType.Address);
        // Lookup the selected item
        int results = engine.Find(ListBox1.SelectedValue,AFD.API.Operation.Retrieve);
        // Assign the address to fields on the Form
        TextBoxOrganisation.Text = engine.GetField("organisation");
        TextBoxProperty.Text = engine.GetField("property");
        TextBoxStreet.Text = engine.GetField("street");
        TextBoxLocality.Text = engine.GetField("locality");
        TextBoxTown.Text = engine.GetField("town");
        TextBoxPostcode.Text = engine.GetField("postcode");
    }
				
			

Appendices

Appendix A

Address Management Product Fields

This currently includes Postcode, Plotter, Postcode Plus & Names & Numbers.

● = Fields returned by this product and fully searchable.
⚬ = Fields returned by this product, but not searchable.

Note: the alternative address formats provided do share some of the same fields where their data is identical, but you should not mix and match other fields between the different formats as this could lead to address corruption. For example, with Standard Address Fields the Street or Locality field could include a street number, whereas with Raw PAF Fields the number would be in the separate Number field.

Field NameDefault SizeDescriptionPostcodePlotterPostcode Plus/Bus.Names & Numbers
Lookup255Specify postcode (or zipcode) and fast-find lookup strings here for lookup operations.
Key255Provides a key which can be used to easily retrieve the record again, e.g. when a user clicks on an item in the list box.
List512Provides a list item formatted to be added to a list box for this record.
Product40Indicates the product name used. [10]
Occupant Fields      
Name120Full name (includes title, first name, middle initial and surname).   
Gender6The gender (M or F) of the resident if known.   
Forename30The first name of the resident.   
MiddleInitial6The middle initial of the resident.   
Surname30The surname/last name of the resident.   
OnEditedRoll6Indicates if the resident is on the edited electoral roll (i.e. they have not opted out). Set to Y if they are on the Edited Roll, N if not, blank for Organisation and other records). To search set to #Y to return only records on the electoral roll, #N only for those not on the electoral roll or !N for all records including Organisations but excluding those not on the Edited Roll.   
DateOfBirth10The residents date of birth if known (electoral roll attainers in the last 10 years only).   
Residency6Gives time in years that the occupant has lived at this address.   
Household Composition106Describes the household composition of the selected address.   
Organisation120Full business name (includes any department).  
Property120Property (building-includes any sub-building).  
Street120Delivery Street (includes any sub-street).
Locality70Locality (sometimes a village name – in ZipAddress used for Urbanization).
Town30Postal Delivery Town (or City).
Postcode10The Royal Mail Postcode for this address (or ZipCode).
Organisation Name60Business Name.  
Department60Department Name.  
Sub Building60Sub Building Name.  
Building60Building Name.  
Number10House Number  
Dependent Thoroughfare60Sub-Street Name.
Thoroughfare60Street Name.
Double Dependent Locality35Sub-Locality Name.
Dependent Locality35Locality Name (Urbanization in ZipAddress).
Identifier8Provides a unique identifier for the address (the Royal Mail UDPRN).  
BuildDate10Provides the build date, which can be used as the start date, entry date, and update date fields for BS7666.  
Administrator20Provides the administrator of the gazetteer (AFD).  
Language5Provides the language (ENG).  
SubUnit60Sub-Unit of a building where needed.  
Building Name60Building name where present.  
Building Number10Building number, including 17A, 17-19, etc. .  
SubStreet60Sub-street where needed.  
Delivery Street60Designated Street Name.
SubLocality60Sub-locality where required.
Delivery Locality60Locality name (or Urbanisation).
Delivery Town30Postal Town name (or City).
Code10The Postcode (or ZipCode).
Postal County30Royal Mail supplied postal county.
Abbreviated Postal County30Royal Mail approved abbreviation is used where available for the postal county.
Optional County30Postal counties including optional ones for most addresses which would otherwise not have a county name.
Abbreviated Optional County30Royal Mail approved abbreviation is used where available for the optional county.
Traditional County30The traditional county name for this postcode.
Administrative County30The administrative county name for this postcode.
Outcode4The Outcode portion of the Postcode (the portion before the space).
Incode3The Incode portion of the Postcode (the portion after the space).
DPS2The Delivery Point Suffix which along with the postcode uniquely identifies the letterbox.  
Postcode From8Used with Postcode field to provide a range for searching. Also returns any changed postcode from a lookup.
Postcode Type6L for Large User Postcode, S for Small User.
Mailsort Code5Used for obtaining bulk mail discounts.
UDPRN8Royal Mail Unique Delivery Point Reference Number assigned to this letter box.  
JustBuilt10AFDJustBuilt – Contains the date of inclusion on PAF for properties thought to be recently built. The date is stored numerically in descending format in the form YYYYMMDD. YYYY is the year, MM is the month and DD is the day. For example 20080304 is 04/03/2008.  
Phone Number Related Fields      
Phone20STD Code or Phone Number.
Geographical Fields      
GridE10Grid Easting as a 6 digit reference. 
GridN10Grid Northing as a 6/7 digit reference. 
Latitude10Latitude representation of Grid Reference in Decimal Format (WGS84). 
GBGridE10UK Based Grid Easting as a 6 digit reference. Always returns the UK based grid even for Northern Ireland addresses. 
GBGridN10UK Based Grid Northing as a 6/7 digit reference. 
NIGridE10Northern Irish Grid Based Grid Easting as a 6 digit reference. Always returns the Irish base grid even for mainland UK addresses. 
NIGridN10Northern Irish Grid Based Grid Northing as a 6/7 digit reference. . 
Longitude10Longitude representation of Grid Reference in Decimal Format (WGS84). 
Miles6Distance from supplied grid reference.  
KM6Distance from supplied grid reference.  
Phone60STD Code or Phone Number.  
Urban Rural Code2Provides a code which indicates if an area is mainly urban or rural and how sparsely populated those areas are. [11]  
Urban Rural Name60Provides a description which goes along with the UrbanRuralCode.  
SOALower9Lower level Super Output Area (Data Zone in Scotland, Super Output Area in Northern Ireland).  
SOAMiddle9Middle level Super Output Area (Intermediate Geography in Scotland, not applicable for Northern Ireland).  
SubCountry Name20Provides the devolved or non-UK country name (e.g. England, Scotland, Wales etc.).  
Ward Code9Code identifying the electoral ward for this postcode.  
Ward Name50Name identifying the electoral ward for this postcode.  
Authority Code9Local/Unitary Authority for this Postcode (same as the start of the ward code).  
Authority50Local / Unitary Authority for this postcode.  
Constituency Code9Parliamentary Constituency Code for this postcode.  
Constituency50Parliamentary Constituency for this postcode.  
Devolved Constituency Code9Devolved Constituency Code for this postcode (currently covers Scotland).  
Devolved Constituency Name50Devolved Constituency Name for this postcode (currently covers Scotland).  
EER Code9Code identifying the European Electoral Region for this postcode.  
EER Name40Name identifying the European Electoral Region for this postcode.  
LEA Code3Code identifying the Local Education Authority for this postcode.  
LEA Name50Name identifying the Local Education Authority for this postcode.  
TV Region30ISBA TV Region (not TV Company).  
Postcode Level Property Indicator Fields      
Occupancy6Indication of the type of occupants of properties found on the selected postcode. [4]
Occupancy Description30Description matching the Occupancy. [4]
Address Type6Indication of the type of property level data to capture to have the full address for a property on the selected postcode. [5]
Address Type Description55Description matching the Address Type. [5]
NHS Code6National Health Service Area Code.  
NHS Name50National Health Service Area Name.  
PCT Code9National Health Service Clinical Commissioning Group Code for England (Local Health Board Code in Wales, Community Health Partnership in Scotland, Local Commissioning Group in Northern Ireland, Primary Healthcare Directorate in the Isle of Man).  
PCT Name50Name matching the PCT Code field.  
Censation Code10Censation Code assigned to this Postcode.
Censation Label50Provides a handle for the Censation Code.
Affluence30Affluence description.
Lifestage100Lifestage description.
Additional Census Info200Additional information from the Census.
Business100Provides a description of the type of business.   
SIC Code10Standard Industry Classification Code for an organisation record.   
Size6Gives an indication of the number of employees of an organisation at this particular office. [7]   
Location Type6The type of Business Location, e.g. Head Office or Branch Office.   
Branch Count6The number of branches for this business.   
Group ID6An ID of the Group were a business is part of a wider group.   
Modelled Turnover15The modelled annual turnover for the business.   
National Size6Gives an indication of the number of employees of an organisation covering all sites. [7]   
Alias Localities4Returns the number of alias records present for the postcode sector in which this result resides.  
Alias Locality35Returns an alias (non-postal) locality that resides in the postcode sector that this address is contained in. Note that many postcode sectors have multiple alias localities and as such you can include this field multiple times to return multiple localities.  
Advanced/Premium Fields      
DataSet15With Postcode Plus and Welsh data can be set to ‘Welsh” to obtain the Welsh language version of an address in Wales where available. If not set then the English language version will be returned. With TraceMaster this indicates an historic dataset to use. [9]   
Council Tax Band6Provides the Council Tax Band for the selected property. Requires Names & Numbers.   

Notes:

[3]     STD Code Only – No Phone Number Present

[4]     Possible Occupancy values and descriptions are as follows (information in brackets not part of the description):

        1. Large User Organisation (Single Organisation on this postcode).
        2. Small User Organisation (All the properties on this postcode are likely to be businesses).
        3. Mostly Organisations (Most of the properties on this postcode are organisations).
        4. Mixed (This postcode contains a mixture of business and residential addresses).
        5. Mostly Residential (Most of the properties on this postcode are residential).
        6. Residential (All the properties on this postcode are likely to be residential).

[5]     Possible Address Type values and descriptions are as follows (information in brackets not part of the description):

        1. Numbered (Only a property number needs to be captured)/
        2. Numbered and Named (This postcode contains a mixture of properties needing a property number and those needing a property name including properties such as 16b).
        3. Numbered and Named, Likelihood of Multiple Occupancy (This postcode contains a mixture of properties needing a property number and those needing a property name. Some of the properties on this postcode are likely to contain multiple occupants, e.g. flats).
        4. Named (This postcode only contains properties needing a property name).
        5. Non-Standard Address Format (This refers to addresses which do not have a street field at all, or have multiple street names on the same postcode. This also includes addresses with numbered localities (no street but a house number which goes in with the locality field). It is in-effect a warning to be careful in capturing the property information as it is not in one of the most common address formats).
        6. PO Box (This postcode has a PO Box number).
        7. No Property Information (Addresses on this postcode have no property information – i.e. capture an Organisation or Resident name only).

[6]    The household composition field includes both a number and description and can have any of the following values.

          1. 1 Male and 1 Female occupant with different surnames.
          2. 1 Male and 1 Female occupant with the same surname (married couples).
          3. Mixed household.
          4. More than 2 persons with the same surname (e.g. older families).
          5. 1 Male Occupant Only.
          6. 1 Female Occupant Only.
          7. More than 7 persons (e.g. old peoples home).

[7]    The Size property can have any of the following values:

A.  1 to 9 employees

B.  10 to 19 employees

C.  20 to 49 employees

D.  50 to 99 employees

E.  100 to 199 employees

F.  200 to 499 employees

G.  500 to 999 employees

H.  1000+

[8]    The phone match type will be set to F if the phone number has been matched to the full name of this resident, or S if just to the surname. This can be useful for identifying the bill payer among multiple residents.

[9]    DataSet property when used with the Names & Numbers TraceMaster product can currently be any of the following years: 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 or Current (for the current data). Only one year can be specified at a time and searches/lookup’s will fail if the specified year has not been installed. New years are automatically accessible when they become available if installed with no change required to the DLL or your application.

[10]    The Product field can have any of the following values:

AFD Postcode
AFD Postcode Plotter
AFD Postcode Plus
AFD Names & Numbers
AFD Names & Numbers TraceMaster

[11]    The Urban Rural Code differs from England and Wales, Scotland and Northern Ireland. The possible codes and there meanings are as follows:

England & Wales

1. Urban (Sparse): Falls within Urban settlements with a population of 10,000 or more and the wider surrounding area is sparsely populated
2. Town and Fringe (Sparse): Falls within the Small Town and Fringe areas category and the wider surrounding area is sparsely populated.
3. Village (Sparse): Falls within the Village category and the wider surrounding area is sparsely populated.
4. Hamlet and Isolated Dwelling (Sparse): Falls within the Hamlet and Isolated Dwelling category and thee wider surrounding area is sparsely populated.
5. Urban (Less Sparse): Falls within urban settlements with a population of 10,000 or more and the wider surrounding area is less sparsely populated.
6. Town and Fringe (Less Sparse): Falls within the Small Town and Fringe areas category and the wider surrounding area is less sparsely populated.
7. Village (Less Sparse): Falls within the village category and the wider surrounding area is less sparsely populated.
8. Hamlet and Isolated Dwelling (Less Sparse): Falls within the Hamlet & Isolated Dwelling category and the wider surrounding area is less sparsely populated

Scotland

S1. Large Urban Area: Settlement of over 125,000 people.
S2. Other Urban Area: Settlement of 10,000 to 125,000 people.
S3. Accessible Small Town: Settlement of 3,000 to 10,000 people, within 30 minutes drive of a settlement of 10,000 or more.
S4. Remote Small Town: Settlement of 3,000 to 10,000 people, with a drive time of 30 to 60 minutes to a settlement of 10,000 or more.
S5. Very Remote Small Town: Settlement of 3,000 to 10,000 people, with a drive time of over 60 minutes to a settlement of 10,000 or more.
S6. Accessible Rural: Settlement of less than 3,000 people, within 30 minutes drive of a settlement of 10,000 or more.
S7. Remote Rural: Settlement of less than 3,000 people, with a drive time of 30 to 60 minutes to a settlement of 10,000 or more.
S8. Very Remote Rural: Settlement of less than 3,000 people, with a drive time of over 60 minutes to a settlement of 10,000 or more.

Northern Ireland

A – E (Urban):
A. Belfast Metropolitan Urban Area
B. Derry Urban Area
C. Large Town: 18,000 and under 75,000 people
D. Medium Town: 10,000 and under 18,000 people
E. Small Town: 4,500 and under 10,000 people
F – H (Rural):
F. Intermediate Settlement: 2,250 and under 4,500 people
G. Village: 1,000 and under 2,250 people
H. Small Village, Hamlet or Open Countryside: Less than 1,000 people

[12]    The record type will be one of the following:

General Delivery
Highrise
Firm
Street
PO Box
Rural Route/Highway Contract
Multi-Carrier Route

Appendix B

BankFinder Fields

This currently includes Postcode, Plotter, Postcode Plus & Names & Numbers.

● = Fields returned by this product and fully searchable.
⚬ = Fields returned by this product, but not searchable.

Note: the alternative address formats provided do share some of the same fields where their data is identical, but you should not mix and match other fields between the different formats as this could lead to address corruption. For example, with Standard Address Fields the Street or Locality field could include a street number, whereas with Raw PAF Fields the number would be in the separate Number field.

C&CCC Related Fields (Not applicable to IPSO Records)

Field NameDefault SizeDescriptionBankFinder
General Fields   
Lookup255Specify postcode (or zipcode) and fast-find lookup strings here for lookup operations.
Clearing System25Clearing system for this record. [3]
Key40Provides a key which can be used to easily retrieve the record again, e.g. when a user clicks on an item in the list box.
List512Provides a list item formatted to be added to a list box for this record.
Product40Provides the product name used. [10]
Search Text255Specify text to search for within any of the BankFinder fields.
General Bank Fields   
SortCode6Bank’s Sortcode.
Bank BIC8Bank BIC Code. [1]
Branch BIC3Branch BIC Code. [1]
Sub Branch Suffix2Allows a branch to be uniquely identified where there is a cluster of branches sharing the same Sort Code. [1]
Short Branch Title27The official title of the branch.
Full Branch Title105Extended title for the institution.
Central Bank Country Code2The ISO Country code for beneficiary banks in other countries.
Central Bank Country Name20The country name corresponding to the ISO code given.
Supervisory Body Code1Indicates the supervisory body for an institution that is an agency in any of the clearings. [2]
Supervisory Body Name50The name of the supervisory body. [2]
Deleted Date10Specifies the date the branch was closed if it is not active.
Branch Type20The branch type – Main Branch, Sub or NAB Branch, Linked Branch.
Main Branch SortCode6Set for linked branches in a cluster. It identifies the main branch for the cluster. For IPSO records this is set to the branch that would handle transactions for this sortcode when the branch has been amalgamated with another.
Location60Where present helps indicate the physical location of the branch.
Branch Name35Defines the actual name or place of the branch.
Alternative Branch Name35An alternative name or place for the branch where applicable.
Owner Bank Short Name20Short version of the name of the Owning Bank.
Owner Bank Full Name70Full version of the name of the Owning Bank.
Owner Bank Code4The four digit bank code of the Owning Bank. [1]
Standard Address Fields (formatted as an address would appear on an envelope)   
Organisation120Owner Bank Full Name.
Property65Bank Postal Address: Property (Building)
Street60Bank Postal Address: Street
Locality60Bank Postal Address: Locality
Town30Bank Postal Address: Town
County30Bank Postal Address: County (Optional)
Postcode8The Royal Mail Postcode for this address.
Raw PAF Fields (formatted closer to how they appear on Raw PAF, useful if your database stores fields this way)   
OrganisationName60Owner Bank Full Name.
SubBuilding60Bank Postal Address: Sub-Building Name
Building60Bank Postal Address: Building Name
Number10Bank Postal Address: House Number
Dependent Thoroughfare60Bank Postal Address: Sub-Street Name
Thoroughfare60Bank Postal Address: Street Name
Double Dependent Locality35Bank Postal Address: Sub-Locality Name
Dependent Locality35Bank Postal Address: Locality Name
Town30Bank Postal Address: Postal Delivery Town
County30Bank Postal Address: County (Optional)
Postcode8The Royal Mail Postcode for this address.
Alternative Postcode Fields   
Outcode4The portion of the postcode before the space.
Incode3The portion of the postcode after the space.
Phone20Phone Number for this bank.
Fax20Fax Number for this bank (IPSO only).
BACS Related Fields (Not applicable to IPSO Records)   
BACS Status5Indicates the BACS Clearing Status. [4]
BACS Status Description60Provides a description for the status. [4]
BACS Last Change10Date on which BACS data was last amended.
BACS Closed Clearing10Indicates the date the branch is closed in BACS clearing if applicable.
BACS Redirected From Flag1Set to R if other branches are redirected to this sort code.
BACS Redirected To SortCode6Set to R if other branches are redirected to this sort code.
BACS Settlement Bank Code4BACS Bank Code of the bank that will settle payments for this branch.
BACS Settlement Bank Short Name20Short form name of the settlement bank.
BACS Settlement Bank Full Name70Full form name of the settlement bank.
BACS Settlement Bank Section2Numeric data required for BACS to perform its settlement.
BACS Settlement Bank SubSection2Numeric data required for BACS to perform its settlement.
BACS Handling Bank Code4BACS Bank Code of the member that will take BACS output from this branch.
BACS Handling Bank Short Name20Short form name of the handling bank.
BACS Handling Bank Full Name70Full form name of the handling bank.
BACS Handling Bank Stream2Numeric code defining the stream of output within the Handling Bank that will be used or payments to this branch.
BACS Account Numbered1Set to 1 if numbered bank accounts are used.
BACS DDI Voucher1Set to 1 if Paper Vouchers have to be printed for Direct Debit Instructions.
BACS Direct Debits1Set to 1 if branch accepts Direct Debits.
BACS Bank Giro Credits1Set to 1 if branch accepts Bank Giro Credits.
BACS Building Society Credits1Set to 1 if branch accepts Building Society Credits.
BACS Dividend Interest Payments1Set to 1 if branch accepts Dividend Interest Payments.
BACS Direct Debit Instructions1Set to 1 if branch accepts Direct Debit Instructions.
BACS Unpaid Cheque Claims1Set to 1 if branch accepts Unpaid Cheque Claims.
CHAPS Related Fields (Not applicable to IPSO Records)   
CHAPSP Status1Indicates the CHAPS Sterling clearing Status. [5]
CHAPSP Status Description80Provides a description for the status. [5]
CHAPSP Last Change10Date on which CHAPS Sterling data was last amended.
CHAPSP Closed Clearing10Indicates the date the branch is closed in CHAPS Sterling clearing if applicable.
CHAPSP Settlement Bank Code3CHAPS ID of the bank that will settle payments for this branch.
CHAPSP Settlement Bank Short Name20Short form of the name of the settlement bank.
CHAPSP Settlement Bank Full Name70Full form of the name of the settlement bank.
CHAPSE Status1Indicates the CHAPS Euro clearing Status. [6]
CHAPSE Status Description80Provides a description for the status. [6]
CHAPSE Last Change10Date on which CHAPS Euro data was last amended.
CHAPSE Closed Clearing10Indicates the date the branch is closed in CHAPS Euro clearing if applicable.
CHAPSE Euro Routing BIC Bank8Specifies the SWIFT closed user group Bank BIC to which CHAPS Euro payments for this branch should be routed.
CHAPSE Euro Routing BIC Branch3Specifies the SWIFT closed user group Branch BIC to which CHAPS Euro payments for this branch should be routed.
CHAPSE Settlement Bank Code3CHAPS ID of the bank that will settle payments for this branch.
CHAPSE Settlement Bank Short Name20Short form of the name of the settlement bank.
CHAPSE Settlement Bank Full Name70Full form of the name of the settlement bank.
CHAPSE Return Indicator1Set to R if this is the branch to which CHAPS Euro payments should be sent.
C&CCC Related Fields (Not applicable to IPSO Records)   
CCCC Status1Indicates the C&CCC clearing status. [7]
CCCC Status Description40Provides a description for the status. [7]
CCCC Last Change6Date on which C&CCC data was last amended.
CCCC Closed Clearing30Indicates the date the branch is closed in C&CCC clearing if applicable.
CCCC Settlement Bank Code3BACS generated code of the bank that will settle payments for this branch.
CCCC Settlement Bank Short Name20Short form of the name of the settlement bank.
CCCC Settlement Bank Full Name70Full form of the name of the settlement bank.
CCCC Debit Agency SortCode50When the Status field is set to ‘D’ this specifies where cheque clearing is handled for this branch.
CCCC Return Indicator6Set if this is the branch that other banks should return paper to. It will only be set for a sortcode of a Member.
Validation Related Fields   
Account Number12The account number to validate (set along with the sort code field for account number validation).
Type Of Account1The type of account field required for transmitting data to BACS when the account number has been translated.
Roll Number20For some building society credit accounts a roll number is required. This can be specified here for validation.
IBAN50The International Bank Account Number. This contains the sort code and account number in a standardised format for cross-border transactions.
Building Society Name70For building society accounts requiring a roll number this will contain the name of the receiving building society as this sometimes differs from the bank branch that the payment passes through.
Card Number20Used to specify a card number to validate.
Expiry Date Optional field to specify an expiry date to validate along with the card number.
Card Type30Indicates the card type following validation. [8]

Notes:

[1]    Does not apply to records in the IPSO (Irish Payment Services Organisation) clearing system.

[2]    The supervisory body code and name can be any of the following:

A.      Bank of England
B.      Building Society Commission
C.      Jersey, Guernsey or Isle of Man authorities
D.      Other

[3]    The clearing system property can have one of the following values:

United Kingdom (BACS) – For branch records for the UK clearing system
Ireland (IPSO) – For branch records on the Irish Payment Services Organisation Clearing System
Both UK and Irish – Returned by Account Number Validation only when a branch is on both systems.

Note, that you should only accept account numbers validated on the Irish system if you can clear through both the Irish (IPSO) system as well as the UK (BACS) system.

[4]    Possible values for the BACS Status and Description fields are as follows:

M.     Branch of a BACS Member
A.      Branch of an Agency Bank
I.       Member of the Irish Clearing Services (IPSO)
          Does not accept BACS Payments

[5]    Possible values for the CHAPS Sterling Status and Description fields are as follows:

M.      Direct Branch of a CHAPS £ Member that Accepts CHAPS £ Payments
A.       Branch of an Agency Bank that Accepts CHAPS £ Payments
I.        Indirect Branch of a Member or Agency Bank that Accepts CHAPS £ Payments
           Does not accept CHAPS £ Payments

[6]  Possible values for the CHAPS Euro Status and Description fields are as follows:

D.      Direct Branch of a CHAPS € Member that Accepts CHAPS € Payments
I.        Indirect Branch of a Member or Agency Bank that Accepts CHAPS € Payments
           Does not accept CHAPS € Payments

[7]  Possible values for the C&CCC Status and Description fields are as follows:

M.      Branch of a C&CCC Member
F.        Full Agency Bank Branch
D.       Debit Agency Branch Only
            Not Part of the C&CCC Clearing

[8]  Possible values for the card type field are as follows:

MasterCard
Visa
American Express
Visa Debit
Electron
Visa Purchasing
UK Maestro
International Maestro
Solo and Maestro
JCB
Charities Aid Foundation
MasterCard Debit

[10]  The Product field would have the value ‘AFD BankFinder’.

WinForms

Introduction

Engine automatically configures itself for many Windows Forms minimising the work you need to do as a developer to get AFD Software working with your application.

This guide is intended to assist you in getting started with using Engine with Windows Forms. It is recommended you read this guide first and then refer to the main manual for advanced settings, if desired, once you have it working.

If you wish to integrate a non-WinForms application or in the backend of any application you should refer to the other .NET API Quick Start Guide instead.

Setup

To use AFD Engine API you first need to install an AFD product (Windows only) or have access to an Evolution server (Java as a client is then completely platform independent). For Windows development and testing you can download data-restricted evaluation products from our website’s evaluation page.

To use AFD Engine API in .NET simply add a Reference to your project to our class library (AFD.API.dll). To do this right click the References item under your project in Solution Explorer select “Add Reference”, and use the Browse Tab to browse to the library file.

Adding to your Windows Form

You can quickly and easily add Address Management functionality to your application with the following steps:

Add the following line to the top of your form’s .cs file:

				
					using AFD.API;
				
			

In the Form_Load method of your form add the following line of code:

				
					Engine engine = new Engine(this);
				
			

If using an evolution server rather than a locally installed product set the Authentication property to an instance of the Authentication class for your server, e.g.:

				
					engine.Authentication = new Authentication("http://myserver:81", "333333", "password");
				
			

You should replace myserver:81 with the name of your server and port, 333333 with your AFD Serial number and password with your password.

When you run your application Engine will attempt to identify address fields on your form. If you type a postcode into any text box on your form you will be prompted to select the correct address for insertion if the user of your application wishes to do so.

In most cases you will want to customise this depending on your requirements to trigger the lookup from a field and button on your form, insert non-address elements etc. and potentially even obtain fields that you do not display on your Form. The following sections detail the options available to do so.

Customisation of Field Mappings

If you require to insert a field on your Form that is has not been detected by Engine or you need to tweak or alter the fields inserted you can easily do this by using the Methods of the Engine.Mapping object.

Engine.Mapping.Add

To add or replace a field mapping for a control on your form, e.g. a TextBox, use the Add method. For example if you have a TextBox Control named “txtCensation” that you want to use for the Censation Code, simply add the following line after instantiating the Engine class:

				
					engine.Mappings.Add(txtCensation, "CensationCode");
				
			

You can additionally specify the following additional parameters to the Add method:

  • UpperCase – (Default false) Specify that the field should be inserted in Upper Case
  • Replace – (Default true) Specifies that any existing value in the TextBox is replaced (if False the field is not inserted unless the field is blank Lines – For use when you use the generic “Address” field with a Multi-line TextBox to specify the number of lines that TextBox contains.

Engine.Mapping.Remove

If you wish to remove a mapping for a field that Engine has mapped that you don’t want included, simply pass that Control to the Remove method: For example if you don’t want a field txtStreet mapped:

				
					engine.Mappings.Remove(txtStreet);
				
			

Engine.Mapping.Clear

This method clears all Mappings and is useful if you wish to change mappings substantially as you can then add each Control you wish to Map yourself using the Add method.

Mapping different Containers on the same Form

When you pass a Form, or keyword this, to Engine it will attempt to auto-detect all Input controls on that Form.

However if you have multiple addresses on the same screen, e.g. a Shipping and Billing address and wish these to be detected separately, simply initialise Engine twice with each of the Containers (e.g. a Frame or Panel) rather than the Form itself.

For example:

				
					Engine engineShipping = new Engine(fraShipping);
    Engine engineBilling = new Engine(fraBilling);
				
			

Triggering Engine from a Button on your Form

By default Engine will auto-detect when you enter a postcode into any field in your application and display matching addresses for the user to choose from.

However to provide full fast-find functionality you can trigger Engine from your own Button on your Form. To do this simply carry out the following steps:

  • Declare the Engine instance at Form level rather than in Form_Load. e.g. place “Engine engine;” above the Form_Load method.
  • In Form_Load change drop the Engine object name from the line that instantiates Engine so that it uses the Form wide variable, i.e. simply use “engine = new Engine(this);”.
  • In your Buttons Click event, use the following line to trigger a fast-find lookup from the contents of a TextBox called txtLookup when that button is clicked: engine.Find(txtLookup.Text, Operation.FastFindLookup);

Engine wlll then insert the selected address in the same way as when Engine auto-detects the Postcode.

If you would prefer Engine to only trigger from your own button when you create an instance of the Engine class use the AutoLookup parameter to disable automatic lookup, e.g. “engine = new Engine(this, true, false);”. (The middle parameter is used to disable automatic configuration of Form fields).

Additional Options for Engine

Engine contains many options for customisation, for example you can control the dialog position and size, its title, icon and other aspects of the Form. You can also carry out a search in the same way as the Lookup above. For full details of these please see the main Engine .NET API guide.

Account and Card Validation

Engine also contains support for Bank account and Debit/Credit card validation if you have BankFinder. For these please see the .NET API Quick Start Guide as there use is not Windows Forms specific.

Integration separate from your Interface logic

Even when displaying a Windows Form you do not need to use Engine in this way. If you prefer to integrate at the backend or manually set and retrieve the fields required you can also do this. For full details please see the .NET API Quick Start guide.

mailLink mailLink

We are here to help

We serve thousands of organisations and a network of hundreds of partners across multiple industry sectors, enabling them to have full confidence in their contact data.