附件从旧版 Salesforce 组织(经典版)迁移到新的 Salesforce 组织(闪电版)

问题描述 投票:0回答:1

我们正在开展两个 Salesforce 平台之间的数据迁移项目。旧版销售人员仍然是经典的,它有 3000 多个案例或客户对象的附件。目标是迁移对象及其附件并将其作为文件存储在闪电版本中。我尝试了 SFDMU 工具并启用(两个组织)上传文件作为文件而不是附件设置。但是,它仍然在目标组织中显示为附件,无法搜索并显示在 UI 上。
我们尽量避免在旧组织中安装任何新的管理包或应用程序,我们选择 SFDMU 的原因是因为开发人员可以在本地安装和运行。

有人可以提供一些指导吗?非常感谢!

salesforce salesforce-lightning
1个回答
0
投票

上传后可以修复吗?

这是丑陋和邪恶的,但在实践中应该足够好。您可能需要对其进行调整以在创建的内容文档上设置共享/可见性字段。

6291456
是 6MB

List<Attachment> source = [SELECT Id
FROM Attachment
WHERE Parent.Type IN ('Case', 'Account') AND BodyLength < 6291456
ORDER by BodyLength DESC
LIMIT 50];

/*  This looks evil (query in a loop, insert in a loop)
    but the idea is that the actual file payload will be kept in the loop as a local variable
    so should be used, inserted and discarded without adding up to heap size and hitting the limit. A proper insert outside of the loop would blow it.
*/
for(Attachment a : source){
    Attachment temp = [SELECT Parentid, Name, Body
    FROM Attachment
    WHERE Id = :a.Id];
    insert new ContentVersion(
        Title = temp.Name,
        PathOnClient = temp.Name,
        VersionData = temp.Body,
        FirstPublishLocationId = temp.ParentId
    );
}
delete source;
Assert.fail('Just checking, please rollback');

这不是精确的科学,在我的测试组织中,它发现的前 50 个附件的大小从 6280972 到 5654213,但运行此命令后,警告是这样的,最大堆大小稍小。

  Number of SOQL queries: 51 out of 100 ******* CLOSE TO LIMIT
  Number of query rows: 100 out of 50000
  Number of DML statements: 51 out of 150
  Number of DML rows: 100 out of 10000
  Maximum CPU time: 6822 out of 10000 ******* CLOSE TO LIMIT
  Maximum heap size: 5785151 out of 6000000 ******* CLOSE TO LIMIT
© www.soinside.com 2019 - 2024. All rights reserved.