Todays blog post will show the code you need to validate an Account address via the UPS Address Validation call you can find in the UPS Shipmate app.
Firstly we will look at the Controller code, and we will explain how it works below:
Lines 7-12: This is where you specify the name of the Account object that you want to validate the address for.
Lines 14-27: We need to get the details of our UPS Shipmate preference and store it into the shipmatePref variable.
Line 29: We create a new zkups_UPSShipment__c object that we will then use to run the validation method against.
Lines 30-34: We add the Account address details to the UPS Shipment object we created in line 29.
Line 36: We create the ValidateAddressResult which is populated by the zkups.ShipmentInterface.validateAddress method. The validateAddress method is the point at which we make the API call out to UPS.
Line 37 – 39: We check if the UPS web service has returned any results, and if so we add it to the validationAddressesList list.
Here is the Visualforce page code that you could link to from the account page that will show you the results of the UPS Address validation results.
Any questions, please do not hesitate to contact us!