StartBatchJob Use Examples
Basic StartBatchJob use
In this example we have three services, one service will get the status of the Batch Job to see if it is running, the StartBatchJob service which will start the batch job, and another service to get the status to show that the Batch Job has started and is running.
Here we have the input to the StartBatchJob service
When we run these three services and view the logs we will see that the first GetStatus has running coming back as “False”
You will also notice that the WindowsProcessId returned wont match the value returned in the StartBatchJob service. That is because GetStatus will get the status of the most current Batch that ran, even if the Batch has stopped.
We will now see the output of the StartBatchJob service with a running of “True” and a new WindowsProcessId (PID)
We can now check the Windows Task Manager to see if the PID matches to a Batch Job running.
As you can see it does.
Next we will view the output from GetStatus showing the WindowsProcessId matching our new Id and the running flag coming back as “True”
Example from Work With Batch Jobs
In this example we have a WebPart that has a list section of all of our Batch Jobs, in the list section there is a run button
In the process of the run button we have three services, one that pulls the values from the page (the important value being the “Name”), the StartBatchJob service, and a service that will refresh the page.
In PreValues a field named Instance is placed into a variable named Instance, in this case Instance is the name.
In the StartBatchJob service we use the Instance value set up in PreValues to start the Batch Job
This shows us that we can set up a Page, in this case “Work With Batch Jobs”, that allows the user to run a batch job by clicking a button using the StartBatchJob service.