使用 Apex Data Loader 将记录加载到具有主详细信息关系的对象中

发布于 2024-09-10 23:10:07 字数 119 浏览 4 评论 0原文

我需要将数据加载到两个对象中。我可以使用数据加载器将数据加载到一个对象中。第二个对象与第一个对象具有主从关系,因此我需要拥有 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寒江雪… 2024-09-17 23:10:08

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

但更好的方法是大声说“管他的 Salesforce ID,我不需要臭 ID”:)
想想你的“师父”是否有一些独特的领域。它甚至可以是您导入到 Salesforce 的现有系统中的“ID”。在 Salesforce 中创建此字段(如果您尚未执行此操作)并将其标记为“外部 ID”。之后,您将能够使用此外部 ID 而不是普通的 Salesforce ID 作为在源和目标之间建立链接的方式。用伪代码表示:

使用普通的 Salesforce ID,您必须

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

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

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

查看 数据加载器用户指南,用于快速启动并使用外部 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.

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:

with normal Salesforce ID you must

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

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")

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.

仄言 2024-09-17 23:10:08

如果您使用 Apex 数据加载器,那么您必须做 3 件事:

1:插入主记录。这将为他们提供 ID

2:再次导出这些主记录(包括其 ID),并将其集成到您的详细信息数据中。 VLOOKUP 对于此类事情最有用。

或者,如果只有一条主记录,则更简单,只需从 URL 中复制 ID 并将其添加到电子表格中的每条详细记录中即可。

3:然后插入带有主ID的明细记录

If you are using the Apex Data loader then you will have to do 3 things:

1: insert the master record(s). this will give them IDs

2: export those master records again including their IDs, and integrate that into your details data. A VLOOKUP is most useful for that sort of thing.

Or if there is only one master record, even easier, just copy the ID out of the URL and add it in on every detail record in your spreadsheet.

3: then insert the detail records with the master IDs

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文