function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hogehogehogehoge 

Help me this Error Apex

global without sharing class ResultFulfillingAggregateScheduler implements Schedulable{
    
    /**
     *  *** AcceptanceExpectedDate is divided into 1st half and 2nd half (1st half: April to September, 2nd half: October to next March)
     *  *** Split timing is based on execution date
     */
    public void execute( SchedulableContext sc ){
        // Get record type
        String conditonRecordTypeA = 'OrderEstimated';
        String conditonRecordTypeB = 'OrderRegistration';
        Map<String,Schema.RecordTypeInfo> recordTypeMap = new Map<String,Schema.RecordTypeInfo>();
        for( Schema.RecordTypeInfo info : Result__c.SObjectType.getDescribe().getRecordTypeInfos() ){
            if( info.getDeveloperName() == conditonRecordTypeA || info.getDeveloperName() == conditonRecordTypeB ){
                recordTypeMap.put( info.getDeveloperName() , info );
            }
        }
        /**

         */
        // Set String value
        List<String> conditionOrderProbabilityRank = new List<String>{ 'A' , 'B' , 'C' };
        // Set conditions for first half and second half
		Date day = Date.today();
        Date startDate = Date.newInstance( day.year() - ( day.month() < 4 ? 1 : 0 ) , ( day.month() >= 4 || day.month() <= 9 ) ? 4 : 10 , 1 );
        Date endDate = startDate.addMonths( 6 ).addDays( - 1 );
        // execute SOQL
        List<Result__c> resultList = [
            SELECT OrderProbabilityRank__c , RecordTypeId , DXSolutionDeptFlg__c , PlatformSolutionDeptFlg__c , DSPSSolutionDeptFlg__c , ManagedServiceDeptFlg__c , EastJapanSolutionDeptFlg__c , ChubuSolutionDeptFlg__c , WestJapanSolutionDeptFlg__c ,  LimitProfit__c , LimitIncomePartTarget__c
            FROM Result__c
            WHERE ( DXSolutionDeptFlg__c = TRUE OR PlatformSolutionDeptFlg__c = TRUE OR DSPSSolutionDeptFlg__c = TRUE OR ManagedServiceDeptFlg__c = TRUE OR EastJapanSolutionDeptFlg__c = TRUE OR ChubuSolutionDeptFlg__c = TRUE OR WestJapanSolutionDeptFlg__c = TRUE )
              AND ( FulfillingAggregateFlg__c = FALSE )
              AND ( AcceptanceExpectedDate__c >= :startDate AND AcceptanceExpectedDate__c <= :endDate )
              AND ( ( RecordType.DeveloperName = :conditonRecordTypeA AND OrderProbabilityRank__c IN :conditionOrderProbabilityRank ) OR RecordType.DeveloperName = :conditonRecordTypeB )
        ];       
        // Save records to aggregate
        Map<String,Result__c> resultMap = new Map<String,Result__c>();
        resultMap.put( '01' , new Result__c( RecordTypeId = recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() , OrderProbabilityRank__c = 'A' , FulfillingAggregateFlg__c = true , SE3__c = 'AAA' , LimitIncomeAchievementSum__c = 0 , LimitIncomeTargetSum__c = 0 ) );

            if( result.RecordTypeId == recordTypeMap.get( conditonRecordTypeA ).getRecordTypeId() && result.OrderProbabilityRank__c == 'A' && result.DXSolutionDeptFlg__c ){
                resultMap.get( '01' ).LimitIncomeAchievementSum__c += result.LimitProfit__c;
                resultMap.get( '01' ).LimitIncomeTargetSum__c += result.LimitIncomePartTarget__c;
            }

        }
        // insert record
        insert resultMap.values();
    }

}

I want to set "AAA" to the se3__c item in the created record, but it is not reflected.
PriyaPriya (Salesforce Developers) 
Hi 

Can you use debug log statement to capture what value getting store in Set3__c ?

Thanks