1

I have a flow as described in the title. If I click on the 'Run' button i receive the following error:

The flow failed to start because the provided values were not valid: Scheduled Flow could only be run from a schedule

If i try with the following code:

Map<String, Object> params = new Map<String, Object>();
Flow.Interview.FlowName thisFlow = new Flow.Interview.FlowName(params);
thisFlow.start();

I receive the same error (as expected):

System.FlowException: The flow failed to start because the provided values were not valid: Scheduled Flow could only be run from a schedule

I tried also this way:

System.schedule('my flow ' + String.valueOf(Datetime.now()), nextFireTime, thisFlow);

and I receive the following:

Method does not exist or incorrect signature: void schedule(String, String, Flow.Interview.FlowName) from the type System

What's the proper way to run such flows?

EDIT: I tried to run the flow as explained in another question creating this class

public class ChargentRecurringInjector_Scheduler implements Schedulable {

    public void execute(SchedulableContext sc) {
        Map<String, Object> params = new Map<String, Object>();
        Flow.Interview.Chargent_recurring_injector_for_scheduledBatchProcessing thisFlow = new Flow.Interview.Chargent_recurring_injector_for_scheduledBatchProcessing(params);
        thisFlow.start();
    }
}

and executing it via System.schedule(...); but, from my developer logs I still can read the same error : "The flow failed to start because the provided values were not valid: Scheduled Flow could only be run from a schedule"

3
  • 1
    Are you trying to test a flow that is run via the new schedule w20 option? Or just trying to figure out how to use the new schedule option?
    – gorav
    Dec 3, 2019 at 13:37
  • Hi @gorav, yes, I would like to run a flow with the new schedule feature to ease the testers work Dec 4, 2019 at 11:03
  • i tested and it looks like you have to remove the schedule to use the 'debug' or 'run' options on the flow. that is silly but fairly easily done. hopefully they will fix that in the future.
    – gorav
    Dec 13, 2019 at 16:31

1 Answer 1

1

Here is the same question and a useful proposed solution from the thread:

public with sharing class MySchedulable implements Schedulable {

  public void execute(SchedulableContext sc) {
    //  Call FLOW to do actual work (no input args)
    new Flow.Interview.MyFlow(new Map<String,Object>()).start();

    //  Call FLOW w/ input args - keys are case sensitive to match Flow variables
    new Flow.Interview.MyOtherFlow(new Map<String,Object> {
       'myVar' => 'abc',
       'myVar2' => 65})
     .start();
  }

}

EDITED >

I recreated the scheduler exactly as you have it using an Auto launched flow I have and could effectively schedule it through dev console with the following lines:

ChargentRecurringInjector_Scheduler m = new ChargentRecurringInjector_Scheduler();
String sch = '0 0 5 * * ?';//Note this will run the flow everyday at 5:00 AM 
String jobID = system.schedule('Your Flow', sch, m);

In case this works for you, here's the reference for the scheduler expression: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm

2
  • it doesn't work, I still receive the same error Dec 4, 2019 at 11:01
  • 1
    I updated my original response with the lines to execute the batch
    – Ideasforce
    Dec 4, 2019 at 20:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .