You need to sign in to do that
Don't have an account?
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.
You can write an onClick JS button on the Account page and can update the address -:
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
var address = sforce.apex.execute("smartyStreetWebserviceClass", "addressValidationMethod", {id:{!Account.Id}});
alert("-------"+address);
Account accountObj = new sforce.SObject("Account");
accountObj.id= '{!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]);
window.location.href=window.location.href;
if (result[0].getBoolean("success")) {
window.alert("Account with id " + result[0].id + " updated");
window.location.href=window.location.href;
} 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.