1

データをサーバーに送信しようとしています。サーバーでは、データが選択され、Salesforce に保存されます。私が取得しているエラーは、サーバーで「null オブジェクトを逆参照しようとしています」です。だから私は問題が何であるか疑問に思っています.以下はサンプルコードです:

public static List<String> processAgentVisitSurvey(ProcessSurveySubmission.SurveySubmission submission, Map<String, Submission_Answer__c> answers, Person__c person) {

    // Load the TDR
    TDR__c tdr = loadTdr(person);

    if (tdr == null) {

        //Send an email saying that an unregistered person is trying to act a TDR

        // Send back the error message
        return new String[] { '0', 'User with handset Id ' + submission.imei + ' is not a TDR', 'SUPRESSMSG' };
    }

これがエラー メッセージのソースです。

このメソッドにリダイレクトするクラスがあります。

private static List<String> additionalProcessing(
        SurveySubmission surveySubmission,
        Survey__c survey,
        Person__c interviewer,
        Id intervieweeId
) {
    List<String> returnValues = new List<String>();

    Map<String, Submission_Answer__c> answers = parseSubmissionToMap(surveySubmission);

    // Find the name of the method that this survey hooks into to do its post processing
    try {
        if (survey.Post_Processing_Method__c.equalsIgnoreCase('None')) {
            returnValues.add('0');
            returnValues.add('There is no post processing method specified for this survey');
            returnValues.add('SUPRESSMSG');
        }
        else if (survey.Post_Processing_Method__c.equals('CKW_Registration')) {
            return CkwRegistration.processCkwRegistration(answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('CKW_Baseline')) {
            return CkwRegistration.processCkwBaseline(answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('CKW_Staff_Update')) {
            return CkwRegistration.processCkwUpdate(answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('Subcounty_Registration')) {
            return CkwRegistration.processSubcounties(answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('TDR_AGENT_VISIT')) {
            return TdrHelpers.processAgentVisitSurvey(surveySubmission, answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('UDOM_RAIN_GUAGE')) {
            return UDoMSurveyProcessing.processDailyRainGauge(surveySubmission, answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('UDOM_RAIN_GUAGE_REG')) {
            return UDoMSurveyProcessing.registerRainGauge(surveySubmission, answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('MTN_CHANNELS')) {
            return MtnChannelsHelpers.processChannelsFFPSSurvey(surveySubmission, answers, interviewer);
        }
        else if (survey.Post_Processing_Method__c.equals('FHI_GROUP_REGISTRATION')) {
        return FHISurveysHelpers.processGroupRegistration(surveySubmission, answers, interviewer, survey.Survey_Name__c);
        }
        else if (survey.Post_Processing_Method__c.equals('FHI_HOUSEHOLD_REGISTRATION')) {
           return FHISurveysHelpers.processHouseholdRegistration(surveySubmission, answers, interviewer, survey.Survey_Name__c);
        }
//           else if (survey.Post_Processing_Method__c.equals('Colombia_Farmer_Registration')) {
//               return ColombiaFarmerRegistrationPostProcessor.processSubmission(surveySubmission, answers, interviewer);
//           }
        else if (survey.Post_Processing_Method__c.equals('FIELD_OFFICER_SUPPORT')) {
            return FieldOfficeHelpers.processFoSurvey(surveySubmission, answers, interviewer);
        }
//           else if (survey.Post_Processing_Method__c.equals('DATA_VALIDATOR_SPOT_CHECK')) {
//               return DataValidatorHelpers.processSpotCheck(surveySubmission, answers, interviewer);
//          }
//            else if (survey.Post_Processing_Method__c.equals('DATA_VALIDATOR_BACK_CHECK')) {
//                return DataValidatorHelpers.processBackCheck(surveySubmission, answers, interviewer);
//            }
        else if (survey.Post_Processing_Method__c.equals('EQUIPMENT_TRACKING')) {
            return EquipmentTrackingHelpers.processFieldOfficerSubmission(surveySubmission, answers, interviewer);
        }
    }
    catch (Exception e) {
        returnValues.add('0');
        returnValues.add(e.getMessage());
        returnValues.add('An error occured. Please contact support');
    }
    return returnValues;
}

私は大丈夫だと思います...

問題がないようですので、助けてください ありがとうございます。コードの提供で十分であることを願っています。

4

2 に答える 2

0

注意: このエラーは、クラスのインスタンス化されていないプロパティを参照しようとした場合にも表示されることがあります。

例: クラスの List プロパティを宣言し、インスタンス化せずにそのリストに追加しようとすると、このエラーが発生します。

于 2015-07-06T05:09:46.260 に答える
0

通常、そのエラーに出くわしたとき、私の最初の本能はクエリを探すことです。APEX では、null 値 (予期されるかどうかに関係なく) を単一のアイテムに返すと、Person__c person = [query that returns objects};そのエラーがスローされます。

解決策は、データが次のような具体的な SObject に返されるようにすることです...

List<Person__c> persons = [Here is a query or method call];

次に、リストを確認して、persons.size() これは Salesforce の Bulkify everything アプローチと、より堅牢なバックエンドに従います。

申し訳ありませんが、これ以上サポートを提供できませんでした。エラーは、行番号やデバッグ ログがないコード サンプルではあまり明白ではありませんでした。

幸運を!

于 2014-12-21T22:06:02.807 に答える