I'm trying to create a custom button that executes javscript on the Case object. I simply want to check if the Case has a specific child record already and forward the user to that record if it exists or to create a new record with specific fields defaulted.
Here is the code I'm using:
{!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")}
var result = sforce.connection.query("SELECT Id FROM Estimate_Price__c WHERE Case__c='{!Case.Id}' AND (Name='Base Price' OR IsBasePrice__c=true)", {
onSuccess : function(result) {
console.debug('RESULT:', result);
var records = result.getArray("records");
if(records.length == 0) {
window.location = '/a0q/e?CF00NL0000003hMbW=00001340&CF00NL0000003hMbW_lkid=500L0000008INOa&retURL=%2F500L0000008INOa&Name=Base Price';
} else {
window.location = '/' + records[0].Id + '/e;
}
},
onFailure : function(error) {
console.debug('ERROR:', error);
log("An error has occurred " + error);
alert('An error occurred. Please contact an admin.');
}
});
This was working about an hour ago and then all of sudden I started receiving the following message:
Any ideas on why this is occurring or how to fix?