Russell Bohl 4 Years Ago Apparently making edits causes the post to be unpublished and sent to review again. Ugh; so here's the edit I was going to make. Link to the Workflow Scripting official docs as currently published: https://portal.liferay.dev/docs/7-0/user/-/knowledge_base/u/leveraging-the-script-engine-in-workflow Please sign in to reply. Reply as... Cancel
Enrico Oliosi 4 Years Ago Hi Russel, I think that's a better choiche move your code into a Java class instead of Groovy script for debug purpose. Do you agree? Please sign in to reply. Reply as... Cancel Russell Bohl Enrico Oliosi 4 Years Ago - Edited Hi Enrico, So, a disclaimer first. I'm not now, nor have I ever been, a "real" developer. I write documentation, so my expertise is somewhat limited. But here's my answer for what it's worth: In general, I find writing scripts, and particularly workflow scripts, very frustrating, for the very reason you pointed out: debugging. It's much harder to track down errors when much of the time you only find them when you re-publish the workflow and have to do runtime testing. So yes, I do think you're correct. If you can complete the same task in a Java class, do it. Now, creating workflows programmatically isn't something I'm familiar with, and I'm not sure if there's a way to extract a script's logic easily into a Java class/module deployed to Liferay. Perhaps you've done this? Please sign in to reply. Reply as... Cancel Enrico Oliosi Russell Bohl 4 Years Ago Yes, look here (sorry for formatting): [...] <assignments> <scripted-assignment> <script><![CDATA[ import com.liferay.portal.template.ServiceLocator; import it.intesys.workflow.util.WorkflowUtil; ServiceLocator serviceLocator = ServiceLocator.getInstance(); WorkflowUtil workflowUtil = (WorkflowUtil) serviceLocator.findService("it.intesys.workflow.util.WorkflowUtil"); roles = workflowUtil.getAssigneRolesWorkflowTask(Long.valueOf(companyId), Long.valueOf(groupId), entryClassName, Long.valueOf(entryClassPK), Long.valueOf(userId)); user=null; ]]> </script> <script-language>groovy</script-language> </scripted-assignment> </assignments> The method "workflowUtil.getAssigneRolesWorkflowTask" (which returns a list roles) offers hospitality to your business logic written in Java so it can be debugged. About test running to check workflow changes I am not able to help you, I think there'isnt any possibities to do it now. Please sign in to reply. Reply as... Cancel Russell Bohl Enrico Oliosi 4 Years Ago Thanks Enrico, that looks like a nice way put the logic into a Java class. Please sign in to reply. Reply as... Cancel
Russell Bohl Enrico Oliosi 4 Years Ago - Edited Hi Enrico, So, a disclaimer first. I'm not now, nor have I ever been, a "real" developer. I write documentation, so my expertise is somewhat limited. But here's my answer for what it's worth: In general, I find writing scripts, and particularly workflow scripts, very frustrating, for the very reason you pointed out: debugging. It's much harder to track down errors when much of the time you only find them when you re-publish the workflow and have to do runtime testing. So yes, I do think you're correct. If you can complete the same task in a Java class, do it. Now, creating workflows programmatically isn't something I'm familiar with, and I'm not sure if there's a way to extract a script's logic easily into a Java class/module deployed to Liferay. Perhaps you've done this? Please sign in to reply. Reply as... Cancel Enrico Oliosi Russell Bohl 4 Years Ago Yes, look here (sorry for formatting): [...] <assignments> <scripted-assignment> <script><![CDATA[ import com.liferay.portal.template.ServiceLocator; import it.intesys.workflow.util.WorkflowUtil; ServiceLocator serviceLocator = ServiceLocator.getInstance(); WorkflowUtil workflowUtil = (WorkflowUtil) serviceLocator.findService("it.intesys.workflow.util.WorkflowUtil"); roles = workflowUtil.getAssigneRolesWorkflowTask(Long.valueOf(companyId), Long.valueOf(groupId), entryClassName, Long.valueOf(entryClassPK), Long.valueOf(userId)); user=null; ]]> </script> <script-language>groovy</script-language> </scripted-assignment> </assignments> The method "workflowUtil.getAssigneRolesWorkflowTask" (which returns a list roles) offers hospitality to your business logic written in Java so it can be debugged. About test running to check workflow changes I am not able to help you, I think there'isnt any possibities to do it now. Please sign in to reply. Reply as... Cancel Russell Bohl Enrico Oliosi 4 Years Ago Thanks Enrico, that looks like a nice way put the logic into a Java class. Please sign in to reply. Reply as... Cancel
Enrico Oliosi Russell Bohl 4 Years Ago Yes, look here (sorry for formatting): [...] <assignments> <scripted-assignment> <script><![CDATA[ import com.liferay.portal.template.ServiceLocator; import it.intesys.workflow.util.WorkflowUtil; ServiceLocator serviceLocator = ServiceLocator.getInstance(); WorkflowUtil workflowUtil = (WorkflowUtil) serviceLocator.findService("it.intesys.workflow.util.WorkflowUtil"); roles = workflowUtil.getAssigneRolesWorkflowTask(Long.valueOf(companyId), Long.valueOf(groupId), entryClassName, Long.valueOf(entryClassPK), Long.valueOf(userId)); user=null; ]]> </script> <script-language>groovy</script-language> </scripted-assignment> </assignments> The method "workflowUtil.getAssigneRolesWorkflowTask" (which returns a list roles) offers hospitality to your business logic written in Java so it can be debugged. About test running to check workflow changes I am not able to help you, I think there'isnt any possibities to do it now. Please sign in to reply. Reply as... Cancel Russell Bohl Enrico Oliosi 4 Years Ago Thanks Enrico, that looks like a nice way put the logic into a Java class. Please sign in to reply. Reply as... Cancel
Russell Bohl Enrico Oliosi 4 Years Ago Thanks Enrico, that looks like a nice way put the logic into a Java class. Please sign in to reply. Reply as... Cancel