2012-06-02 135 views
0

有人可以看看它。下面是代碼和錯誤必填字段missng錯誤

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 
    } 

處理器類看起來是這樣的

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

第一個錯誤:插入失敗。第0行的第一個例外;第一個錯誤:REQUIRED_FIELD_MISSING,缺少必填字段:[Name]:[Name]

回答

4

Account字段是必需的,因爲它在Salesforce中的幾乎所有標準對象上。就像你不能通過ui創建一個沒有名字的賬戶一樣,你不能通過設置名稱字段來插入賬戶記錄,如下所示:

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