Question / Problem:
How do I create a SubJob using the API? There is no CreateSubJob API (or similar) on the documented list of API's.
Answer / Solution:
By definition, the parent job will wait for the subjob to complete. Since there is no CreateSubJob API, the CreateJob API has to be used which will create a separate job. But both the parent and child job will execute to completion simultaneously.
To mimic the subjob behavior, preconditions and events need to be used to make this work. The parent process would need a WAIT event and the node after the CreateJob node would have a precondition configured, such as WAIT > 0. This means the job will not move past this node until at least 1 instance of the WAIT event was registered against the job.
The "subjob" created from the CreateJob API would call JobService.RaiseEvent() as it’s last step. This would fire the WAIT event against the main parent job which would allow the parent job to progress.