首页 > 解决方案 > Contact RecordType 不能设置为通过 API 联系

问题描述

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

标签: c#soapsalesforce

解决方案


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

推荐阅读