我创建了一个C#项目,将Salesforce Enterprise WSDL连接为WebReference并尝试创建联系人
var recordTypes = sforceService.query("select Id from RecordType where sObjectType = 'Contact'");
var contact = new Contact
{
LastName = textTemplate,
RecordType = (RecordType)recordTypes.records[0],
Email = textTemplate + "@test.com",
Phone = "1234567890",
};
res = sforceService.create(new sObject[] { contact });
并得到一个错误:
"Field name provided, Id is not an External ID or indexed field for RecordType"
在这种情况下如何设置RecordType?
UPD。我应该填写string RecordTypeId
字段而不是RecordType RecordType
字段
RecordTypeId = recordTypes.records[0].Id
答案 0 :(得分:0)
ID recordTpeId=Schema.SObjectType.Contact.getRecordTypeInfosByName().get('recordTypeName').getRecordTypeId();