cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to create a single workflow for multiple products

Former Member
0 Kudos
296

Assume that there are three products P1,P2,P3. Single workflow should be created for all the three products, meaning single workflow will have 3 products as an attachments.

I tried creating workflow using AfterSaveListener when a new product is added or editing the existing product but it is creating the single workflow for each product. I mean, if there are 3 products then it is creating 3 workflows, not single workflow for 3 products.

Please help, how to achieve this ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

in backoffice you can manually create a workflow with many attachments. If you want to react to events (like save) you have some options:

  • hook-in to the logic that does the bulk operation on the data (then you will have all the needed references)

  • react to the save events and store the data you want to attach + create a cron job to start the workflow from-time-totime

  • create a cron job that will be able to fetch the changed items to st wrkflow (the best option, no additional persistence needed)

Cheers, Wojtek

Former Member
0 Kudos

Thanks for the suggested approaches.

Lets consider the 3rd approach, In my case, i will receive an impex file which contains list of products(say 20 products) and i have to trigger a single workflow for all the 20 products once the 20th product is imported. Here how i will be able to call the save event while importing the last product (how do i determine the product is the last product ?) .

Answers (1)

Answers (1)

Former Member
0 Kudos

I do have similar situation. I'm using 6.7 version. I want to trigger only one instance of workflow template for all 10 or 20 products. Below is the line of code I am using in impex file to trigger a workflow. But it triggers n instances of workflow template where n is number of rows in my impex file.

"#%groovy% afterEach: workflowService.createWorkflow(workflowTemplateService.getWorkflowTemplateForCode('wfl_template_name'), modelService.get(impex.lastImportedItem))"

Please let me know if there is a way with which we can achieve this. Just like "afterEach" is there a method "äfterLast". Please suggest.