AEM trigger workflow from Java - Create translation project | AEM Community Blog Seeding


Community Manager



AEM trigger workflow from Java - Create translation project by Ravi Pampana


Triggering workflow from Java and automate the process to create translation project using workflow.

Code snippet

import com.day.cq.workflow.model.WorkflowModel;
import com.day.cq.workflow.WorkflowService;


private WorkflowService workflowService;

WorkflowSession wfSession = workflowService.getWorkflowSession(session);
// We can have any workflow model here - For creating language copy I am using create_language_copy workflow.

String workflowName = "/var/workflow/models/wcm-translation/create_language_copy";
// Get the workflow model

WorkflowModel wfModel = wfSession.getModel(workflowName);

String languageEnMasterPath = "master page path";
// Get the workflow data

// Workflow Data - Provide the master language page path from where the language copy to be created
WorkflowData wfData = wfSession.newWorkflowData("JCR_PATH", languageEnMasterPath);

// Add meta data values
final Map<String, Object> workflowMetadata = new HashMap<>();
workflowMetadata.put("model", "/etc/workflow/models/wcm-translation/create_language_copy/jcr:content/model");

// If parent pages to be auto created when not present - false to not create
workflowMetadata.put("createNonEmptyAncestors", true);

// Pass true if child pages to be created
workflowMetadata.put("deep", false);
workflowMetadata.put("projectFolderLanguageRefCount", "Count of total language masters available");

// Pass comma separated languages list like en,fr,es etc. For only 1 language pass workflowMetadata.put("language", "fr")
workflowMetadata.put("languageList", "comma separated language list");

//Pass project type - add_structure_only will create only structure no translation will happen
workflowMetadata.put("projectType", "add_structure_only");
workflowMetadata.put("projectTitle", "");

// Run the Workflow.
wfSession.startWorkflow(wfModel, wfData, workflowMetadata);

Read Full Blog

AEM trigger workflow from Java - Create translation project


Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager