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;
        return 'NoGrievanceError';

Here is the javascript in the button:


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.


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.

  • Is this happening in one of your sandboxes? Did you refresh your sandbox recently. Are you seeing the same error consistently in PRD and All sandboxes?
    – Rao
    Apr 24, 2014 at 22:30
  • This is in my production environment. I am seeing it consistently on all records.
    – Chris
    Apr 24, 2014 at 22:32
  • if(grievance!= null) in your submitAndValidateGrievance(){ method, what does this collection contain how are you populating this collection?>
    – Rao
    Apr 24, 2014 at 22:49
  • It is not a collection but a variable for a custom object. The custom object has the fields Status__c and Submission_Date__c. The grievance is being queried in the SubmitGrievanceController constructor. The constructor takes an ID and instantiates it data member "grievance" with the result from the query.
    – Chris
    Apr 25, 2014 at 0:39
  • 1
    Did you keep any of the internal server error Ids? Raising a support case with the internal Id might give you more clues about the cause. Apr 30, 2014 at 1:32

1 Answer 1


These sort of errors are tough, but you have some options.

1. Contact support and get the GACK details

If you email support the details of the internal server they can look it up on there back-end and find a stack trace. In many cases the stack trace may give a much clearer picture of what the error is and allow you to work around it.

2. Binary Search plus Trial and Error Workarounds

Use a binary search algorithm to identify the specific line of code leading to the error. In other words, comment out one half of the code, if the error still occurs, comment out the other. Keep reducing the amount commented out until you end up with a single line.

If you get to this point try and put yourself in the mind of the developers who built the underlying Salesforce functionality. What sort of things might be tricky to implement? What sort of things could lead to errors if not handled properly? Use trial and error to see if you can alter anything about the code to get the error to go away while still accomplishing your goal. Hack it to pieces, whatever it takes to work around the error and get back to working on new features.

3. Contact support and get their help

If your issues is consistently reproducible you can contact support and have them do the troubleshooting. This is not fun. Support is much better at handling user issues than platform bugs. It can take a very, very long time to even get support to understand the error, let alone believe it's something that's broken. Many a time I find a bug, work through endless emails, calls, and goto meetings only for them to tell me it's a known issue (that's not on the known issues list), and they won't fix it for fear that fixing the bug might break someone else's code (aka the "Bug as a Feature Response").

That said, if you stick with it, you'll get to the real support guys (Tier 3 and R&D) who are very skilled and can assist in fixing the issue. Provided of course, you don't mind waiting 3 months to a year for a patch to go out. And at the end of event, you'll get the satisfaction you made Salesforce just a little bit better.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.