Salesforce 数据库记录和执行调控器的虚拟更新
我需要触发 Salesforce 数据库中大量记录的更新,而无需真正更新任何值。这是为了制作一些公式来重新计算一些字段。
这是我尝试过的 - 一个可调度的类(假设我希望它每晚运行):
global class acmePortfolioDummyUpdate implements Schedulable
{
global void execute(SchedulableContext SC)
{
for (Acme_Portfolio__c p : [Select Id From Acme_Portfolio__c]) {
update(p);
}
}
}
update(p) 是一个 DML 语句,Salesforce 将它们的数量限制为 150。在我的例子中,大约有几千条记录。
另外,我需要在许多不同的投资组合中执行此操作。 SF 将预定课程的数量限制为 10 人。
有什么解决方法吗? 谢谢
I need to trigger updates of a whole bunch of records in a Salesforce database without really updating any values. This is to make a few formulas to recalculate some fields.
Here's what I tried - a schedulable class (say I want it to run every night):
global class acmePortfolioDummyUpdate implements Schedulable
{
global void execute(SchedulableContext SC)
{
for (Acme_Portfolio__c p : [Select Id From Acme_Portfolio__c]) {
update(p);
}
}
}
update(p) is a DML statement and Salesforce limits the number of them to 150. In my case it's about a few thousands of records.
Also, I need to do this across many different portfolios. SF limits the number of scheduled classes to 10.
Any workaround for this?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试批量 Apex。您可以使用可调度的类来安排您的批次。如果我错了,请纠正我,但每次您阅读公式时,它们不是都会重新计算吗?
编辑:评论空间不足。
我不能保证这会编译(现在无法访问组织),但请尝试这样的操作:
并从系统日志运行此操作:
Try Batch Apex. You can schedule Your batch using schedulable class. Correct me if I'm wrong but aren't formulas recalculated each time You read them?
Edit: Comment don't have enought space.
I'm not guarantee this will compile (dont have access to org right now), but try sth like this:
And run this from system log: