First question to the Salesforce StackExchange; I apologize in advance for not adhering to any community rules.
I'm trying to execute an Apex method through the anonymous execution via Developer Console. Part of the overall process involves kicking off a Process Builder process. I know that the Process Builder doesn't support bulk operations so I was purposely trying to de-bulkify the method. The method is supposed to loop through a list of Ids and mimic going to a Visualforce page and clicking a button. My code is thus:
public class ManualScorecardSend {
public void sendScorecard() {
Rare_Campaign__c [] cResults = [SELECT Id FROM Campaign__c where Status__c = 'Active'
AND Program__r.Name IN ('SomeProgram')];
For (Campaign__c c: cResults) {
SetupNewScoreCardExtension setupnsc = new SetupNewScoreCardExtension(new ApexPages.StandardController(c));
setupnsc.SendScorecard();
}
}
}
ManualScorecardSend mss = new ManualScorecardSend();
mss.sendScorecard();
Every time I execute this code I get the 'too many SOQL' queries error from Process Builder. But if I go to the V-force page for each Id and kick off the process manually, it works fine.
For further information, the total number of Ids that result from my SOQL query is like 30. Not talking about a lot of records here. I just wanted to write up something quick to execute these processes so I wouldn't have to go to 30 different V-force pages and do them manually until the scheduling part of the project was set up.
Please let me know if you have any questions or need more information.
Apex Trigger
. SomeApex Triggers
are not so well designed and will perform worse. It's not a dichotomy between "supported" and "unsupported," but rather a scale whereProcess Builder
sits somewhere in the middle. – Adrian Larson♦ Jun 29 '15 at 17:55