cancel
Showing results for 
Search instead for 
Did you mean: 

Modified pbm_packages for parallel tasks

tullo1
Champ in-the-making
Champ in-the-making
For two parallel tasks in the beginning of a workflow I need two different sets of documents visible to the users working with the tasks.

So, lets say the workflow is started with 5 documents to review, currently the users for both tasks "Approve Document Internal" and "Approve Document External" can see all the documents in the pbm_package.

But the external guys should only have to review the two documents with a specific metadata value set.

I was thinking about creating a new pbm_package for the task "Approve Document External" and copy over the children of the original pbm_package which have the metadata set? would that work?

Or is there a simpler/better solution to achieve the described scenario?

Regards
Andreas

For a bit more info please have a look at https://forums.alfresco.com/forum/developer-discussions/workflow/bpmpackage-splitting-11052013-2011
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
Add an additional association to your content-model (eg. add a new aspect and add it to your start-task model and all task-models). This association should have target-class of "cm:content" and many=true.

Next, in your form-config, add the new field to the field-visibility and add a "<field" entry, using the packageitems.ftl as control). This way, the new association will be rendered the same as the normal package-items, but will hold a different set of documents.

frederikherema1
Star Contributor
Star Contributor
I was a bit quick, only covered the "displaying" usecase for this. You still need to add a step (e.g. script-step or script-task-listener or actual Service-task with Java class associated) that copies the 2 documents to the new property. If you only add the "new" property to the visibility on the external-reviewers-form, the'll only see those documents. Keep in mind, though, they still have access to the main workflow details (since they are involved in the process), so they can see the normal package-items, when looking into workflow details. Offcourse, if the external users don't have permissions on the 3 remainging documents, they won't be shown in the items-view…

tullo1
Champ in-the-making
Champ in-the-making
Thanks for your  input Frederik! I followed your suggestion and introduced custom aspects to mark the docs only relevant to external reviewers. The two user groups now only see the documents relevant to them. Unfortunately the current solution has the side effect that the documents no longer are marked (indicator) as being part of a workflow if the documents are moved to a package visible only to the task instance.
<code>
<activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
    <activiti:field name="script">
        <activiti:string>
            importClass(Packages.java.util.Calendar);
            var activiti = Packages.org.alfresco.repo.workflow.activiti;
            var ctx = Packages.org.springframework.web.context.ContextLoader.getCurrentWebApplicationContext();
            if (bpm_workflowDueDate != null){
                task.dueDate = bpm_workflowDueDate;
            } else {
                // task due 14 days from now
                var fortnightFromNow = Calendar.getInstance();
                fortnightFromNow.add(Calendar.DAY_OF_MONTH, 14);
                task.dueDate = fortnightFromNow.getTime();
            }
            var serviceReg = ctx.getBean("ServiceRegistry");
            var localDocs = new Array();
            var candidate = undefined,
            contractor = false;
            for (var i = 0; i &lt; bpm_package.children.length; i++) {
                candidate = bpm_package.children;
                contractor = candidate.hasAspect("someco:interfaceContractor");
                if (contractor) {
                    var contractorValue = new java.lang.String(candidate.properties["someco:interfaceContractor"]);
                    if(contractorValue.contains("ABB")){
                        localDocs.push(bpm_package.children);
                    }
                }
            }
            var pckg = workflow.createPackage();
            if(localDocs.length &gt; 0) {
                for (var k = 0; k &lt; localDocs.length; k++) {
                    pckg.addNode(localDocs[k]);
                    bpm_package.removeNode(localDocs[k]);
                }
            }
            else {
                //taskService.complete(task.getId()); // TODO figure out why this always throws an exception
            }
            pckg = new activiti.ActivitiScriptNode(pckg.nodeRef, serviceReg);
            var taskService = ctx.getBean("activitiTaskService");
            taskService.setVariableLocal(task.getId(), "bpm_package", pckg);
        </activiti:string>
    </activiti:field>
</activiti:taskListener>
</code>
Axel, on the Alfresco thread, mentioned that he among other strategies uses form filters to achieve the result I am looking for. I guess I'll have a look into at that approach so that I can get around the side effect mentioned above.

frederikherema1
Star Contributor
Star Contributor
Great, thanks for sharing the solution you created!
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.