"Invalid field for upsert, must be an External Id custom or standard indexed field: Name" 错误

"Invalid field for upsert, must be an External Id custom or standard indexed field: Name" error

我正在尝试为联系人对象输入唯一值。这是代码:

List<Contact> conList = new List<Contact> {
        new Contact(FirstName='Joe',LastName='Smith',Department='Finance'),
        new Contact(FirstName='Kathy',LastName='Smith',Department='Technology'),
        new Contact(FirstName='Caroline',LastName='Roth',Department='Finance'),
        new Contact()};   

// Caroline Roth already exists so I want this code to update her record, not insert another Caroline Roth record          
Database.UpsertResult[] srList = Database.upsert(conList, Contact.Fields.Name, false);

Salesforce 的文档说明 "The upsert statement matches the sObjects with existing records by comparing values of one field. If you don’t specify a field when calling this statement, the upsert statement uses the sObject’s ID to match the sObject with existing records in Salesforce. Alternatively, you can specify a field to use for matching. For custom objects, specify a custom field marked as external ID. For standard objects, you can specify any field that has the idLookup property set to true. For example, the Email field of Contact or User has the idLookup property set."

我有两个问题: 1) 我们如何查看 Contact 对象上的哪些字段将其 idLookup 属性 设置为 true 2) 为什么我在执行代码时会在主题行中收到错误?

1:

Map<String, Schema.SObjectField> contacFieldsMap = Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap();

for (Schema.SObjectField field : contacFieldsMap.values()) {
    Schema.DescribeFieldResult fieldResult = field.getDescribe();
    if (fieldResult.isIdLookup()) System.debug(fieldResult.getName() + ' IS idLookup');
}

2: System.debug(Contact.Name.getDescribe().isIdLookup()); // false