搜索

110.13. 使用 Salesforce Composite API 提交 SObject 树

download PDF

要创建最多 200 个记录,包括父子关系,请使用 salesforce:composite-tree 操作。这需要一个 org.apache.camel.component.salesforce.api.dto.composite.SObjectTree 实例,并在输出消息中返回相同的对象树。树中的 org.apache.camel.component.salesforce.api.dto.AbstractSObjectBase 实例会使用标识符值 (Id 属性) 或对应的 org.apache.camel.component.salesforce.api.dto.composite.SObjectNode 实例进行更新,并在失败时生成 errors

请注意,对于某些记录操作可能会成功,对于某些记录操作可能会失败,您可能需要手动检查错误。

使用此功能的最简单方法是使用 camel-salesforce-maven-plugin 生成的 DTO,但您也可以选择自定义识别树中每个对象的引用,用于来自您的数据库的实例主密钥。

我们来看一个例子:

Account account = ...
Contact president = ...
Contact marketing = ...

Account anotherAccount = ...
Contact sales = ...
Asset someAsset = ...

// build the tree
SObjectTree request = new SObjectTree();
request.addObject(account).addChildren(president, marketing);
request.addObject(anotherAccount).addChild(sales).addChild(someAsset);

final SObjectTree response = template.requestBody("salesforce:composite-tree", tree, SObjectTree.class);
final Map<Boolean, List<SObjectNode>> result = response.allNodes()
                                                   .collect(Collectors.groupingBy(SObjectNode::hasErrors));

final List<SObjectNode> withErrors = result.get(true);
final List<SObjectNode> succeeded = result.get(false);

final String firstId = succeeded.get(0).getId();
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.