Users receive an error when clicking a custom button when using Internet Explorer web browser of;
"A problem with the ONClick JavaScript for this button or link was encountered:
Object doesn't support property or method 'startsWith'"
Note that this error only occurs when using Internet explorer.
The code for my custom button is below. Is there anything I can do to get this working?
{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/29.0/apex.js")}
var r = confirm("Warning: this will make the R&D Project or Service available for Salesforce Opportunities, once they are added to a price list. Do you wish to proceed?");
if(r==true) {
var result = sforce.apex.execute("availableForOpportunities","convertToOpportunity",
{product2:"{!Product2.Id}"});
location.reload = '/'+result[0].Id+'/e';
// Check result in console window
console.log(result[0]);
// If this result starts with a string equal to the id key for the object type you are accessing, relocate the browser to that page
if (result[0].startsWith('001')) {
location.reload = '/' + result[0] + '/e';
} else {
// Otherwise, show the error message to the viewer
alert(result[0]);
location.reload(true)
}
}