【问题标题】:How to get status of the workflow from related the document ? , About Folder Rule Script of Alfresco如何从相关文档中获取工作流的状态? , 关于Alfresco的文件夹规则脚本
【发布时间】:2018-09-11 21:42:45
【问题描述】:

我想在“工作文件夹”和“进行中文件夹”之间移动文档 当我开始我们的 Alfresco 的工作流程时,根据工作流程的状态。这些文件夹是我在 Alfresco 的站点中创建的。

文件夹规则脚本的以下代码无法通过我的尝试工作。那么,你知道吗,如何从相关文档中获取工作流的状态?我想,想更新脚本。

var parentFolder = document.parent;
var WFstatus = workflow.parameters["bpm:status"];
if (WFstatus.indexOf('In progress') != -1){
    var dest = parentFolder.parent.childByNamePath("2.InProgress");
    document.move(dest);
}

Alfresco 版本:社区版 5.2 & 企业版 5.2.4

最好的问候,

【问题讨论】:

    标签: javascript alfresco alfresco-share alfresco-webscripts


    【解决方案1】:

    请确认,我的理解。

    是否要根据工作流状态正确地将两个文件夹之间的文件“工作文件夹”移动到“进行中文件夹”?

    工作流状态可以是活动(正在运行)和已完成,但当前任务的状态可以是“进行中”。

    这里是 Javascript 控制台代码,用于获取所选文档的工作流程和任务状态。

    //Get the parents for the document node.
    //If the document is attached to the workflow, then there will be multiple parents.
    for(var x=0;x<document.parents.length;x++)
    {
        var t = document.parents[x];
        var workflowNode;
        //Pick the bpm:package node. 
        if (t.type == "{http://www.alfresco.org/model/bpm/1.0}package")
        {
            workflowNode = t;
            logger.log(t);
            //Get the workflow instance Id
            var wfId = t.properties["bpm:workflowInstanceId"];
            logger.log(wfId)
    
            //get the workflow instance
            var rwf = workflow.getInstance(wfId);
            logger.log(rwf);
            logger.log("Workflow status : " + rwf.active);
    
    
            for (var pid in rwf.paths) 
            {
               var path = rwf.paths[pid];
               //Get the tasks and its status
               for (var tid in path.tasks)
               {
                 var task = path.tasks[tid];
                 logger.log(task);
                 logger.log("Task id : "  +  task.id +" task status :" + task.properties["bpm:status"])
               }
             }
        }   
    
    }
    print("\n");
    print("\n");
    print("\n");
    print("\n");
    

    当您获得任务状态后,您应该能够在文件夹之间移动文件。

    希望对你有帮助!!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多