on ‎2019 Jan 16 9:56 PM
I'm working with hybris version 6.7 and creating a new customized workflow, the idea is trigger the workflow each time a new instance of a new type is created. In a POC for the workflow, in a bc2_acc recipe I created the new type code and the WorkflowTemplate.
This is the impex to create the workflow template
INSERT_UPDATE WorkflowTemplate; code[unique = true]; name[lang = en] ; owner(uid); description[lang = en] ; activationscript
; PlayerHireWorkFlow ; Hire a new player ; admin ; Template to player hire workflow ; "action.equals('create') &&
((de.hybris.platform.servicelayer.type.TypeService) Registry.getApplicationContext().getBean('typeService')).isAssignableFrom('Player', itemType.getCode())"
If I trigger the workflow using the workflowProcessingService.startWorkflow(workflow); command a a groovy script it works perfectly.
I put a breackpoint on the DefaultScriptEvaluationService.evaluateActivationScripts method but is never invoked when a new item is created.
Is anything missing?
Thanks
Request clarification before answering.
I tried with your suggestion Arvind but it hasn't worked. The only thing I had to change was the quotes to be able to import the impex. What is rare to me is that I even tried with a semantically wrong activation script and I did not see any error, is like it's not being evaluated at all.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi - did you import my code as it is? I have used the code successfully for Product itemtype. The only thing that I have left in the ImpEx is visibleForPrincipals(uid) which I thought you already knew where to include. I have updated my answer and included the code that I have already executed successfully.
Please try the following:
INSERT_UPDATE WorkflowTemplate;code[unique=true];name[lang=en];owner(uid);description[lang=en];activationscript
;PlayerHireWorkFlow;Hire a new player;admin;Template to player hire workflow;
(("create".equals(action) && initialValues != null) ||
("save".equals(action) && currentValues != null)) &&
((de.hybris.platform.servicelayer.type.TypeService) Registry.getApplicationContext().getBean("typeService")).isAssignableFrom("Player", itemType.getCode())
Please note that the code that I have written above is based on the following code which I have already used successfully for Product itemtype:
INSERT_UPDATE UserGroup;UID[unique=true];groups(uid)[mode=append]
;testproductmgrgrp;backofficeproductmanagergroup,employeegroup
INSERT_UPDATE Employee;UID[unique=true]
;testlocmgr
$START_USERRIGHTS
Type;UID;MemberOfGroups;Password;Target;read;change;create;remove;change_perm
Employee;testlocmgr;;1234;;;;;;
;;;;Workflow;+;+;;;;
;;;;WorkflowAction;+;+;;;;
Type;UID;MemberOfGroups;Password;Target;read;change;create;remove;change_perm
Employee;testproductmgr;;1234;;;;;;
;;;;Workflow;+;+;;;;
;;;;WorkflowAction;+;+;;;;
$END_USERRIGHTS
UPDATE Employee;UID[unique=true];description;name;groups(uid);sessionLanguage(isocode);sessionCurrency(isocode)
;testlocmgr;Localization manager;Localization Manager;testproductmgrgrp;en;EUR
;testproductmgr;Product manager;Product manager;testproductmgrgrp;en;EUR
INSERT_UPDATE WorkflowTemplate;code[unique=true];name[lang=en];owner(uid);description[lang=en];visibleForPrincipals(uid);activationscript
;SampleWorkFlow;Product Workflow;admin;This is an sample workflow template which is started when a product approval status has been changed in the platform to check;testproductmgrgrp;\
(("create".equals(action) && initialValues != null && initialValues.get("approvalStatus") != null && "check".equals(initialValues.get("approvalStatus").getCode())) ||\
("save".equals(action) && currentValues != null && currentValues.get("approvalStatus") != null && "check".equals(currentValues.get("approvalStatus").getCode()))) && \
((de.hybris.platform.servicelayer.type.TypeService) Registry.getApplicationContext().getBean("typeService")).isAssignableFrom("Product", itemType.getCode())
INSERT_UPDATE WorkflowActionTemplate;code[unique=true];name[lang=en];principalAssigned(uid);workflow(code)[unique=true];actionType(code)
;SampleAction1;Product Localization;testlocmgr;SampleWorkFlow;start;
;SampleAction2;Validation of Localization;testproductmgr;SampleWorkFlow;normal;
;SampleAction3;End;testproductmgr;SampleWorkFlow;end;
INSERT_UPDATE WorkflowDecisionTemplate;code[unique=true];name[lang=en];actionTemplate(code);
;LocalizationDone;Localization done;SampleAction1;
;LocalizationRejected;Localization rejected;SampleAction2;
;LocalizationApproved;Localization approved;SampleAction2;
INSERT_UPDATE WorkflowActionTemplateLinkTemplateRelation;source(code)[unique=true];target(code)[unique=true];andConnectionTemplate;qualifier;
;LocalizationDone;SampleAction2;true;WorkflowActionTemplateLinkTemplateRelation;
;LocalizationRejected;SampleAction1;true;WorkflowActionTemplateLinkTemplateRelation;
;LocalizationApproved;SampleAction3;true;WorkflowActionTemplateLinkTemplateRelation;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I tested with your impex and did not work, is there any additional step to start evaluate the activation scripts?
You can see attached the impexes I ran (link text), as I understand once I import the test_products.impex one workflow instance should be created right?
Thanks
Hi - this workflow activates when you access backoffice with testproductmgr/1234 and create a new product or change the status of an existing product to check. After that, when you will access backoffice with testlocmgr/1234, you will see that there is a pending task for localization which when completed, will assign a task to the testproductmgr to approve it. I just tested it and found it working correctly.
But...when I created a product by importing an ImpEx script, the workflow did not trigger. I will look into it and get back to you.
I made a test creating the products from backoffice and worked as you said. I also tried to change my workflow activation script and link it with Product type instade of Player type and it was triggered. What did not work is when I created the Player type from backoffice, in this case the scripts where not evaluated (based on the breakpoints). I'm investigating, but it seems that the workflow triggering is attached to the backoffice product creation and not to the item creation / save or delete as the documentation says.
An activation script is evaluated each time an item is: Created Saved Removed
https://help.hybris.com/6.7.0/hcd/8c878e7286691014b3aaf108edc38cca.html
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.