c# - 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
解决方案
ID recordTpeId=Schema.SObjectType.Contact.getRecordTypeInfosByName().get('recordTypeName').getRecordTypeId();
推荐阅读
- python-3.x - 如何为存储为字典中的值的数据框提供文本键?
- rest - 当前用户与 ID 的 REST 端点
- azureservicebus - 逻辑应用未缩放以匹配 ServiceBus 吞吐量
- html - 表单输入的奇怪 iOS 设备特定问题
- java - 创建通用数组列表时应该首选哪种方式?
- python - 根据 Pandas 中列中的列表值从 DataFrame 中选择行
- aws-appsync - 当 AWS AppSync 使用 Cognito 时如何验证 Lambda 生成的突变
- sql - SQL:解析列分隔符(缩短脚本)
- autocomplete - 当用户单击任何站点时隐藏 ul
- c# - IO 异常 (XML) - 进程无法访问该文件,因为它被另一个进程使用