Required field missng Error

LivingThing Source

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;
    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]



answered 6 years ago John Sullivan #1

The Name field is required on accounts, as it is on almost all standard objects in Salesforce. In the same way that you cannot create an account through the ui without a name, you cannot insert account records without giving them a name by setting the Name field like so:

Account acc = new Account();
acc.Name = 'Some Name';

comments powered by Disqus