使用 Apex Data Loader 将记录加载到具有主详细信息关系的对象中 [英] Using Apex Data Loader to load records into object with master details relationship

查看:17
本文介绍了使用 Apex Data Loader 将记录加载到具有主详细信息关系的对象中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将数据加载到两个对象中.我能够使用数据加载器将数据加载到一个对象中.第二个对象与第一个对象具有主从关系,因此我需要在 CSV 文件中具有第一个对象的记录的唯一记录 ID.如何将这些记录 ID 添加到我的 CSV 文件中?

I need to load data into two objects. I am able to load data into one object using the data loader. The second object has a master-details relationship with the first object so I need to have the unique record id of the records of first object in the CSV file. How can I add those record id's to my CSV file?

推荐答案

您可以在初始上传后下载主"记录并执行一些类似于 (Name -> Id) 的映射.在 Excel 中,这可以通过 VLOOKUP 实现.生成新的详细信息"对象列表后,上传它们应该没有问题.Apex Data Loader 创建的成功日志文件中也提供了映射ID->上传的记录".

You could download the "master" records after initial upload and perform some mapping similar to (Name -> Id). In Excel this could be achieved with VLOOKUP. Once you have generated new list of "detail" objects, there should be no problem uploading them. The mapping "ID->uploaded records" is also available in the success log file created by Apex Data Loader.

但更好的方法是大声说搞砸 Salesforce ID,我不需要臭 ID":)想想你的主人"是否有一些独特的领域.它甚至可以是您从现有系统导入 Salesforce 的ID".在 Salesforce 中创建此字段(如果您尚未创建)并将其标记为外部 ID".之后,您将能够使用此外部 ID 而不是普通的 Salesforce ID 作为在源和目标之间建立链接的一种方式.在伪代码中:

But the better way is to say loudly "screw the Salesforce ID, I don't need no stinking ID" :) Think if your "master" has some unique field. It can even be the "ID" from your existing system from which you import to Salesforce. Create this field in Salesforce (if you didn't do it already) and mark it as "External ID". Afterwards you will be able to use this external ID instead of normal Salesforce ID as a way to make the link between source and target. In pseudocode:

您必须使用普通的 Salesforce ID

with normal Salesforce ID you must

INSERT INTO detail_object (Name, SomeValue, master_ID) VALUES ("foo", "bar", [some valid salesforce id])

使用外部 ID,您可以轻松地告诉 Salesforce 完成所有繁重的工作

With external IDs you can have it easy and tell salesforce to do all the heavy lifting

INSERT INTO detail_object (Name, SomeValue, master_ID) VALUES ("foo", "bar", (SELECT Id from master_object where some_field_marked_as_external_id = "123")

查看Data Loader 用户指南以快速入门和使用如果可以的话,使用外部 ID(可能在免费的开发者版中?).使用比描述更容易.

Check out the Data Loader user guide for quick start and play with external ids if you can (in the free developer edition maybe?). It's easier to use than to describe it.

这篇关于使用 Apex Data Loader 将记录加载到具有主详细信息关系的对象中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆