function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

I would like to add a custom button to Account page that calls SmartyStreet application on demand.

 I would like to add a button in the Address section of the standard Account page that would call the smartyStreet app update the address. We already use SmartyStreet software for Address Verification. It is currently called only inside our account trigger handler when a new account is added or an address is modified. The problem is we have thousands of records that were not verified during initial Data Load. The current work around is to make an non address change change for example change address from 123 N 1st St to 123 N 1st Street and press Update. Hoping to do this with just a simple button press.
Best Answer chosen by Eric_Arizona
Hi Eric,

You can write an onClick JS button on the Account page and can update the address  -:

var address = sforce.apex.execute("smartyStreetWebserviceClass", "addressValidationMethod", {id:{!Account.Id}});
Account accountObj = new sforce.SObject("Account"); '{!Account.Id}';

// Here you need to handle the address[0] value by looking the alert , what comes first 
accountObj.address =address[0];

var result = sforce.connection.update([accountObj]);

if (result[0].getBoolean("success")) {
window.alert("Account with id " + result[0].id + " updated");
} else {
window.alert("failed to update the account" + result[0]);

>> smartyStreetWebserviceClass >> Webservice classname
>> addressValidationMethod >> Methodname >> parameter >> AccountId

Let me know if you have any query.