Add address autocomplete

Procedure

  1. Create an AddressAutocompleteHandler instance in the appropriate PCF file.

    You create the instance by calling the factory method gw.api.contact.AddressAutocompleteHandler.createHandler with the following arguments:

    • A String identifying the field to complete
    • A comma-separated list of the reference fields, field names of the Address entity, that the application passes to the handler
    • A Boolean value that specifies whether PolicyCenter waits for a key press before fetching suggestions
  2. Edit the PCF file in Guidewire Studio and add the factory method in the Variables tab of the PCF widget, calling the method in the initialValue field.
    Suppose that you want to construct an AddressAutocompleteHandler called cityhandler in the GlobalAddressInputSet.default.pcf file. In that case, you need to first add the cityhandler variable in the Variables tab, then set its various fields as follows:
    initialValue
    contact.AddressAutocompleteHandler
           .createHandler("City","City,County,State,PostalCode,Country",true)
    name
    cityhandler
    recalculateOnRefresh
    false
    From the method call, you can see that this handler operates on the City field. The handler requires the following set of reference fields: City, County, State, PostalCode, and Country.
  3. Edit the widget that uses the handler to specify which handler is responsible for autofill in the autoComplete property and the arguments the handler expects in the autoCompleteArgIds field.
    For example, for AddressAutoFillInput: City:
    action
    gw.api.contact.AddressAutocompleteUtil
          .autofillAddress(addressOwner.AddressDelegate,"City")
    actionAvailable
    addressOwner.AutofillIconEnabled
    autoComplete
    cityhandler
    autoCompleteArgIds
    City,County,State,PostalCode,Country
    available
    addressOwner.isAvailable(fieldId.CITY)
    This example uses an AddressAutoFillInput widget for the city field. This widget displays an autofill icon beside the field that acts as a cue. You do not have to use this specific type of widget for this purpose.