0

有人可以看看它。下面是代码和错误

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,缺少必填字段:[名称]:[名称]

4

1 回答 1

4

客户需要名称字段,因为它位于 Salesforce 中的几乎所有标准对象上。就像您无法通过没有名称的 ui 创建帐户一样,您无法通过设置 Name 字段来插入帐户记录而不给它们一个名称,如下所示:

Account acc = new Account();
acc.Name = 'Some Name';
database.insert(acc);
于 2012-06-02T23:21:59.900 回答