This extension changes a backend error that appears when a user attempts to delete an address that is already in use. The error message in this scenario reads “Unexpected Failure,” the error returned iserrorCode : "ERR_WS_REMOVE_CUSTOMER_ADDRESS" errorMessage : "Unexpected failure" errorStatusCode : "400"
but we need to change it to a different message. will provide a sample code below which is used in SuiteScript
define("Address.Remove", [
"Address.Model",
"Application",
"SC.Models.Init",
"underscore",
], function (
AddressModel,
Application,
ModelsInit,
_
) {
"use strict";
_.extend(AddressModel, {
remove: function (id) {
try {
return ModelsInit.customer.removeAddress(id);
}
catch (e) {
var promise = Application.processError(e);
if (promise.errorCode === "ERR_WS_REMOVE_CUSTOMER_ADDRESS") {
throw 'This address cannot be removed because it is being used.';
} else {
return ModelsInit.customer.removeAddress(id)
}
}
}
});
});