无法将Contact RecordType设置为“通过API联系”

时间:2019-07-11 13:40:22

标签: c# api soap salesforce

我创建了一个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

1 个答案:

答案 0 :(得分:0)

ID  recordTpeId=Schema.SObjectType.Contact.getRecordTypeInfosByName().get('recordTypeName').getRecordTypeId();