I wanted to double check on my scheduler to make sure is was compiled correctly. I need it to run every minute, which is not possible, so I have it scheduled for every 15 minutes. Testing is difficult because I have to wait 15 minutes every time I want to test one change. Is there a way around this?
While I am waiting for the newest change I wanted to check with you guys to see if everything looked okay. I am getting failed Status Details but because the limit is 255 characters, I am unable to see the entire failure string. So I am trying to troubleshoot (slowly...every 15 minutes. sadface). Also, why is it skipping scheduled job 1?
Apex:
global class AutoStartSchedulerUpdateStageName {
global void AutoStartSchedulerUpdateStageName() {}
public static void start()
{
System.schedule('Scheduled Job 1', '0 0 * * * ?', new AutoStartScheduler());
System.schedule('Scheduled Job 2', '0 15 * * * ?', new AutoStartScheduler());
System.schedule('Scheduled Job 3', '0 30 * * * ?', new AutoStartScheduler());
System.schedule('Scheduled Job 4', '0 45 * * * ?', new AutoStartScheduler());
}
}
global class AutoStartScheduler implements Schedulable {
global void execute(SchedulableContext SC) {
AutoStartSchedulerLogic a = new AutoStartSchedulerLogic();
}
}
global with sharing class AutoStartSchedulerLogic {
global AutoStartSchedulerLogic(){
List<Opportunity> brokerAPIOppty = [SELECT Id FROM Opportunity WHERE CreatedBy.Name = 'nfapi Site Guest User' AND StageName = 'Identified' AND RecordType.Name = 'Broker WC Oppty'];
if(!brokerAPIOppty.isEmpty()){
for(Opportunity o : brokerAPIOppty) {
o.StageName = 'Statements In - MCA';
}
update brokerAPIOppty;
}
}
}
UPDATE: Triggers and Callouts dislike each other so a future method is needed. Future methods can't return values back into the flow because of sync/async issues. All other workarounds (ie: updating a field in sf with the webservice values etc..) caused order of execution issues/"uncommitted work pending".
The ideal flow we need is:
- Third Party Insert
REST
service calls apex class- apex updates Opportunity field
- Opportunity Trigger fires
- class is called
- this class calls the flow and passes input parameters
- flow is called
- flow wait element is called
- flow calls an apex class that:
webservice
is called in this class- platform events are created in this class
- flow resumes when platform event is published
- continues logic...
Two callouts are creating the loop error.