InstanceKey determines the number of typeahead sessions that the user has consumed. It ensures that users are charged each time they look up a new address and not each time a call is made to the Spectrum OnDemand server with their keystrokes as they use the typeahead feature.
Let us see this with an example, where Taylor is using the typeahead feature for address validation.
- Taylor starts to type the address. On the first keystroke, the InstanceKey is set to empty string. The call goes to the Spectrum OnDemand server and the return value has an InstanceKey.
- As Taylor keeps typing, the call is made to the Global Type Ahead service, which returns the list of addresses.
- Taylor selects a address and a call is made to the server (to validate the address) assuming the application is configured to use Address Validation service.
- This InstanceKey is passed every time a call is made to the server to validate
the address. It determines the uniqueness and differentiates the addresses used.
You cannot use same InstanceKey for two different addresses.
For example, Ship to address will have a different InstanceKey than the Ship from address.
- Taylor finds the required validated address and selects it, or for some reason, Taylor cancels the operation. In both the scenarios, as soon as the operation ends, the InstanceKey is discarded.
- Taylor (or any other user) starts typing another address. On the first
keystroke, the InstanceKey is set to empty string and the value is returned with
a new
InstanceKey.
Use a new InsanceKey, every time you discard or look for a new address.