I have a piece of code that has been working for the past few months without problem until recently. I cannot say to the exact day this started happening as this is still in a testing phase and this portion was untested for a short while. I am getting an "Internal Salesforce.com Error" message inside of my debug logs when I attempt to update my custom object. This action is being called through a custom button using javascript. A error message of "Invalid Cross Reference ID" gets returned to the screen when the button is pressed.
My button that calls a webservice method:
webService static String SubmitGrievance(String grievanceID){
SubmitGrievanceController.isSubmitting = true;
SubmitGrievanceController ctrl = new SubmitGrievanceController(grievanceID);
return ctrl.submitAndValidateGrievance();
}
This simply instantiates an object of the class it is inside of and calls a method that runs custom validation checking on the object.
Here is the submitAndValidateGrievance method:
public String submitAndValidateGrievance(){
if(grievance != null){
//GrievanceCustomValidationRules gcvr = new GrievanceCustomValidationRules(this.grievance);
String returnString = 'Pass';
//String returnString = gcvr.validateGrievance();
if(returnString == 'Pass'){
//grievance.Status__c = 'Open';
//grievance.Submission_Date__c = date.today();
update grievance;
}
return returnString;
}
else{
return 'NoGrievanceError';
}
}
Here is the javascript in the button:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var conf = confirm("Select OK to confirm grievance submission.");
if (conf == true) {
var gID = "{!Grievance__c.Id}";
var result = sforce.apex.execute("SubmitGrievanceController",
"SubmitGrievance", {
grievanceID : gID
});
if (result == 'Pass') {
window.location.href = '../AppLogin/a00/o';
}
}
I can post the GrievanceCustomValidationRules code if necessary but nothing inside of there that changes any values on my custom object or updates anything. It is simply checking that certain related objects exist. The debug logs gets through the custom validation portion and the last call is an DML statement attempting to update my grievance object.
I should also note that I have no problems updating any of the existing objects through the standard edit page. If I edit the same object that I attempt to use this button on, set the fields to "Open" and set the date as today - it saves without problem.
EDIT
I removed the custom validation rules just to assure that nothing in there was causing the issue and I am still receiving it. Literally the only thing that I am doing is modifying two fields and updating the custom object.
EDIT # 2
I updated the above code to reflect my current attempts.
I completely changed the webservice method to do everything inside of there so that you guys can see the code in its entirety. The code below does not do anything that I need it and I am simply just querying for it and then trying to update it immediately after to see if I still receive the error and I do.
webService static String SubmitGrievance(String grievanceID){
//SubmitGrievanceController.isSubmitting = true;
//SubmitGrievanceController ctrl = new SubmitGrievanceController(grievanceID);
system.debug('Grievance ID: ' + grievanceID);
Grievance__c grievance = [SELECT Id,Grievant_s_Union__c,Grievance_Sub_Type__c,Suspension_Days__c FROM Grievance__c g WHERE g.Id = :grievanceID];
system.debug('Grievance ID #2: ' + grievance.Id);
//update grievance;
Grievance__c updateGrievance = new Grievance__c(Id = grievanceID, Status__c = 'Open', Submission_Date__c = date.today());
update updateGrievance;
return '';
}
Adding KeithC's suggestion did not get rid of the error.
EDIT # 3
I have changed the connection.js to a more recent release. API 30. Still having problems.
EDIT # 4
So at around 9:30 PM 4/28/2014 this code began to function normally. The exact code that you see in this post is now operating as intended with no changes. I have no clue as to what may have caused this only that the Spring '14 release was put on our server weekend before last, April 17-18.