https://joao.ws/how-to-assign-a-workflow-dynamically-in-aem/
How to assign a workflow dynamically in AEM