通过 Web 脚本推进 Alfresco 工作流程

发布于 2024-08-24 23:05:16 字数 258 浏览 10 评论 0原文

我有一个 Alfresco 文档参考;我正在寻找的是一种访问附加到该文档的工作流程并通过 Javascript 完成它(或将其进行到下一个转换)的方法。

网络上几乎每个示例都展示了如何启动工作流程,如果我知道任务 ID,我可以从仪表板调用任务命令处理器 (/alfresco/command/task/end/[/transition]),但我该如何执行仅从文档参考开始的服务器端 Web 脚本有同样的事情吗?

必须有一种方法可以从文档访问工作流程并以编程方式管理它们。

I have an Alfresco document reference; what I'm looking for is a way to access workflow attached to that document and finish it (or progress it to the next transition) through Javascript.

Almost every example on the web shows how to start workflow, and from the dashlet I could call task command processor (/alfresco/command/task/end/[/transition]) if I knew the task ID, but how do I do the same thing from server-side web script starting only from the document reference?

There must be a way to access workflows from document and manage them programatically.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ˉ厌 2024-08-31 23:05:16

从文档 nodeRef 中,您可以像这样发出当前任务的信号:

var docNodeRef = "workspace://SpacesStore/<GUID HERE>";
var transitionId = "some action";
var theDocument = search.findNode(docNodeRef);
foreach  (currWorkflow in theDocument.activeWorkflows)
{
    var path = currWorkflow.paths[currWorkflow.paths.length-1];
    var task = path.tasks[0];
    for (var transitionKey in task.transitions)
    {
        if (task.transitions[transitionKey] == transitionId)
        {
            path.signal(transitionId);
            break;
        }
    }
}

如果您想发出默认转换的信号,您可以跳过内部循环,只需执行以下操作:

var docNodeRef = "workspace://SpacesStore/<GUID HERE>";
var transitionId = "some action";
var theDocument = search.findNode(docNodeRef);
foreach  (currWorkflow in theDocument.activeWorkflows)
{
    var path = currWorkflow.paths[currWorkflow.paths.length-1];
    var task = path.tasks[0];
    // Signal default transition
    path.signal(null);
}

From a document nodeRef you can signal the current task like this:

var docNodeRef = "workspace://SpacesStore/<GUID HERE>";
var transitionId = "some action";
var theDocument = search.findNode(docNodeRef);
foreach  (currWorkflow in theDocument.activeWorkflows)
{
    var path = currWorkflow.paths[currWorkflow.paths.length-1];
    var task = path.tasks[0];
    for (var transitionKey in task.transitions)
    {
        if (task.transitions[transitionKey] == transitionId)
        {
            path.signal(transitionId);
            break;
        }
    }
}

If you want to signal the default transition you can skip the inner loop and just do this:

var docNodeRef = "workspace://SpacesStore/<GUID HERE>";
var transitionId = "some action";
var theDocument = search.findNode(docNodeRef);
foreach  (currWorkflow in theDocument.activeWorkflows)
{
    var path = currWorkflow.paths[currWorkflow.paths.length-1];
    var task = path.tasks[0];
    // Signal default transition
    path.signal(null);
}
笨死的猪 2024-08-31 23:05:16

好吧,我仍然不知道如何过渡,但我发现了一些事情。

首先,我可以访问工作流程文档参与并取消它:

for each (workflow in document.activeWorkflows) {
    workflow.cancel();
}

但是,我仍然不太确定如何进度任务。我可以到达任务并用它做一些事情:

var task = workflow.getTask(taskId);
task.endTask(transitionId);

...但我仍然不知道如何以编程方式或通过 Alfresco 到达任务 ID 或过渡 ID。

编辑:弄清楚了,transitionId实际上是工作流processdefinition XML中定义的转换名称:

<transition name="SomeTransitionId" to="end">

此外,要从工作流中获取任务列表,您可以迭代路径(workflow.getPaths()),然后使用path.getTasks()迭代任务。

Well, I still don't know how to transition, but there are a couple of things I found out.

First, I can access workflows document participates in and cancel it:

for each (workflow in document.activeWorkflows) {
    workflow.cancel();
}

However, I'm still not quite sure how to progress tasks. I can get to the task and do something with it:

var task = workflow.getTask(taskId);
task.endTask(transitionId);

...but I still have no idea how to get to taskId or transitionId, either programmatically or through Alfresco.

EDIT: figured it out, transitionId is actually transition name as defined in workflow processdefinition XML:

<transition name="SomeTransitionId" to="end">

Also, to get list of tasks from the workflow you can iterate through paths (workflow.getPaths()) and then through tasks with path.getTasks().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文