More Dynamic Way to Schedule a Salesforce Flow with Invocable Schedule Flow

Image 00 How this solution works

Attributes

Image 01 Where to Find your Flow API Name
Image 02 Sample Screen to Formulate a Flow Job
Image 03 Sample Screen to formulate a Flow Job
Image 04 Sample Screen to invoke the InvocableScheduleFlow based on Screen on previous screen
Image 05 Debug screen to formulate Flow Job
Image 06 Debug execution of InvocableScheduleFlow
Image 07 Debug Screen after InvocableScheduleFlow
Image 08 Go to Developer Console -> Debug -> and click Open Execute Anonymous Window
Image 09 Put the script, set your attributes into the Anonymous Window, and check the Open Log checklist
List<InvocableScheduleFlow.Request> requests = new List<InvocableScheduleFlow.Request>();
InvocableScheduleFlow.Request req = new InvocableScheduleFlow.Request();
req.flowApiName = 'Dummy_ScheduledFlow'; //mandatory
req.cronExpression = '0 45 22 ? * FRI-MON'; //mandatory
req.scheduleJobName = 'TestDummy_ScheduledFlow'; //mandatory
req.flowNamespace = null; //optional
req.flowParameterName = 'parameter'; //optional
req.flowParameterValue = 'This is a value'; //optional
req.runInFuture = false; //will set to false if null or not set
requests.add(req);
List<InvocableScheduleFlow.Result> results = InvocableScheduleFlow.invoke(requests);
System.debug(results[0].jobId); //the job id result
Image 10 Click execute, checklist Debug Only, and you’ll have the Job ID that created to run your flow job
Image 11 Result of the flow Job I created (see the email timestamp)
Image 12 Go to Setup and search for Scheduled Jobs
Image 13 You’ll see the list of Scheduled Jobs and when it will be run. Notice that the Job Name we set on the parameter will appear there
Image 14 Go to setup and search for Apex Jobs
Image 15 You’ll see the current status of the job you created with ScheduledFlow in the Apex Class field
Image 16 Click Del at the job you wanted to abort

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store