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
salmanmanekiasalmanmanekia 

Required field missng Error.. Help

Hi,

 

Can someone have a look at it. Below is the code and the error

 

global void execute(
        Database.BatchableContext BC,
        List<sObject> listObj){
            
            list <Account> inAcc = new list<Account>();
            for (sObject lo : listObj){
                Unprocessed_Agreement__c temp = (Unprocessed_Agreement__c)lo;
                inAcc.add(processor.processAccountRecord(temp));
                }
            insert(inAcc); // This line throws the error
            }

 

 

the processor class looks something like this

 

global class CreateAndModifyProcessor {
    global Account processAccountRecord( Unprocessed_Agreement__c temp){
        Account tempAcc = new Account();
        tempAcc.Begining__c = temp.Begining__c;
        tempAcc.Agreement_ID__c = temp.Agreement_ID__c;
        return tempAcc; 
    }
}

 

First error: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name]

Best Answer chosen by Admin (Salesforce Developers) 
Shashikant SharmaShashikant Sharma

Hi,

 

just change this code to 

 

global class CreateAndModifyProcessor {
    global Account processAccountRecord( Unprocessed_Agreement__c temp){
        Account tempAcc = new Account();
        //you can use any other logic to set the name as it is required you need to specify it in insert
        tempAcc.Name = 'Test Account'; 
        tempAcc.Begining__c = temp.Begining__c;
        tempAcc.Agreement_ID__c = temp.Agreement_ID__c;
        return tempAcc; 
    }
}

 let me know if you still face issues.

All Answers

Shashikant SharmaShashikant Sharma

Hi,

 

just change this code to 

 

global class CreateAndModifyProcessor {
    global Account processAccountRecord( Unprocessed_Agreement__c temp){
        Account tempAcc = new Account();
        //you can use any other logic to set the name as it is required you need to specify it in insert
        tempAcc.Name = 'Test Account'; 
        tempAcc.Begining__c = temp.Begining__c;
        tempAcc.Agreement_ID__c = temp.Agreement_ID__c;
        return tempAcc; 
    }
}

 let me know if you still face issues.

This was selected as the best answer
salmanmanekiasalmanmanekia

Thanks Shashikant !

Shashikant SharmaShashikant Sharma

Your welcome salmanmanakia .