A popular request among users of the Batch module is the ability to grab the job instance id in any of a Batch job’s phases. Why is that useful? Well, there could be a number of useful scenarios:
If the batch communicates with an external system, it’s sometimes useful to pass the local job instance id for reference and management purposes
To improve the job’s custom logging
Some jobs might want to fire email or SMS notifications for meaningful events, having the job instance id in those messages is obviously helpful.
The id will be exposed throw a flow variable of key ‘batchJobInstanceId’. That flow variable will be available since the very beginning of the input phase. It will also be available on every step and in the on-complete phase. Let’s see an example job:
As you see this job is pretty simple. In all its phases, it invokes a sub-flow which logs the output of #[flowVars[‘batchJobInstanceId’]]. The log output that it produces is the following:
So that’s it. This is a small, easy to use improvement which I hope you’ll find useful. Have any other examples of how the job instance id can be useful? Please share!
Imagine, integrate, and innovate at the #1 integration event