Create a new button on the Contact object (Display Type: Detail Page Button, Behaviour: Execute JavaScript) and put this javascript on it:
{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")} var postcode = '{!Contact.MailingPostalCode}'; if (postcode != '') { postcode = postcode.replace(' ','%20'); sforce.connection.remoteFunction({ url : 'http://api.postcodes.io/postcodes/'+postcode+'/validate', async : true, cache : false, method: "GET", onSuccess : function(response) { if (response.slice(-5) == 'true}') { alert('OK'); } else { alert('Wrong - check using https://www.royalmail.com/find-a-postcode'); } }, onFailure : function(response) { alert('ERROR: '+response); } }); }For the Account object use
{!Account.BillingPostalCode}
or
{!Account.ShippingPostalCode}as appropriate.
No comments:
Post a Comment