Alfresco Content Services - Blog

cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco Content Services - Blog

menczingerm
Active Member

Description:

My goal was to delete all active and completed tasks and workflows in ACS and here is some information what i found out untill i could reach my goal. 

Conclusions

  • Workflow Console "delete all worfklows imeanit" command only delete active tasks and workflows
  • Trying to undeploy and redeploy a workflow definistion name with workflow conolse will delete completed workflows related to that workflow definition but it will not remove the completed tasks - undeploying a workflow definition will cause you a problem - completed task without deployed definition  (link
    Exception (with status template): 01030136 Failed to execute script 'Javascript Console Script': null
    org.springframework.extensions.webscripts.WebScriptException: 01030006 Wrapped Exception (with status template): 01030136 Failed to execute script 'Javascript Console Script': null
        at org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1139)
  • With Alfresco RestApi you are not able to manage completed tasks/workflows only active tasks/workflows
  • I also found out someone managed to delete completed task/workflows with deleting records directly in the DB, how ever i did not investigate this deeply.

Solution:

So the solution what worked for me is to write a custom javascript code what i could run with javascript console to remove completed task and workflows in the repository.

Here is the script:

var ctxt = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
var service = ctxt.getBean('WorkflowService', Packages.org.alfresco.service.cmr.workflow.WorkflowService);
var activitiProcessEngine = ctxt.getBean('activitiProcessEngine', Packages.org.activiti.engine.impl.ProcessEngineImpl);

var activitiUtil = new org.alfresco.repo.workflow.activiti.ActivitiUtil(activitiProcessEngine, false);
var historyService = activitiUtil.getHistoryService();


var completedWorkflows = service.getCompletedWorkflows();

while(completedWorkflows.size() > 0){
    var wfToDelete = completedWorkflows.remove(0);
    var id = wfToDelete.getId();

    historyService.deleteHistoricProcessInstance(id.substr(9));
    logger.log("WF deleted: " + id);

    completedWorkflows = service.getCompletedWorkflows();

}

The script tested with ACS 5.2 CE AND ACS 6.2 CE

I would like to thank my colleagues at BroadBit Hungary and @angelborroy  @openpj for their help

Ps.: If you have any comment or suggestion please dont hasitate to post it.

Read more
1 1 735
Jatherton
Active Member II

android.png

 

I am pleased to announce that the brand new Alfresco Mobile Workspace is live in the app stores! Links in the article.

Read more...

Read more
2 0 827
Jatherton
Active Member II

The source code for the Alfresco Mobile Workspace is now available on GitHhub!

Top-10-IT-SUPPORT-ISSUES-3.png

Read more...

Read more
2 1 896
EddieMay
Alfresco Employee

Some repos were recently made read-only - here's why...

Read more...

Read more
4 0 1,650
Jatherton
Active Member II

android.png

It is with great excitement that I can announce this early access release of the Alfresco Mobile Workspace, a brand new mobile app for content management.

What is the Alfresco Mobile Workspace?

The Alfresco Mobile Workspace is a brand new mobile application with a similar look and feel to the Alfresco Digital Workspace. Out of the box the Mobile Workspace is the perfect companion for the Digital Workspace allowing users to seamlessly interact with content across the web and mobile.

Read more...

Read more
6 2 3,574
Alfresco Content Services Blog