I have an Activiti workflow that creates multiple (parallel) user tasks for an authorisation task (assigns each one to a group based on one element of a list).
<userTask id="authReview" name="Authorisation Review" activiti:candidateGroups="${assignee}" activiti:formKey="rowf:authReviewTask">
<documentation>
${assignee} Data Access request for approval.
</documentation>
<!-- One instance of this user task for each group that needs to authorise the request -->
<multiInstanceLoopCharacteristics isSequential="false"
activiti:collection="${rowf_reviewers}" activiti:elementVariable="assignee" >
</multiInstanceLoopCharacteristics>
</userTask>
As the ${assignee} variable is used to allocate the task to the correct group (after being read from the ${rowf_reviewers} list, is there any way to use ${assignee} to add to the task description?
The task description is currently set by the tag which seems to work fine but nothing is read from ${assignee}. I think this may be to do with a timing issue with the population of ${assignee} as "may" be populated before the gets evaluated.
Any assistance on how to get ${assignee} into the description would be appreciated.
I think what you are asking is if you can update the task description to include the assignee.
You can do this easily in a task listener on the "create" event.
Using the task Delegate (DelegateTask), simply call the setDescription method.
Let me know if I have misundersrood your need.
Greg
I have prepared simple jUnit test which works:
github jUnit test
I hope it helps.
Regards
Martin
Related
Occasionally in our codebase we need to use an //eslint-disable to bypass a styleguide rule on a line. I would like to somehow automatically add a comment on each new instance of that in PRs, requiring the developer to explain why they bypassed the styleguide.
I've found this question referencing how to create a comment programmatically, but what I'm not sure how to do is identify the new code and parse it for a certain piece of text, then add comments on those particular lines where the text was found.
This is one of the approaches to ingest scripts & achieve what you want, wherein Expected outcome is:
On every pull request, a pre build validation pipeline kicks off & adds comments on the PR.
Create a script (powershell/python/bash) with following logic:
Find file names in the given branch which contains //eslint-disable
In the files above (1.), get the location/line number of //eslint-disable
Foreach file.LineNumber (wrote like that just for representation): add comment on file.LineNumber using Pull Request Threads API. See line parameter
Create a pipeline containing above script & add that pipeline as build validation or if you have an existing build validation process, add these scripts as tasks in that pipeline.
Hope this helps :)
Please, observe:
That's it. That is all a task that is a Task Group has. Compare that to just a task:
So what is the deal with the Task Groups? They look like a half-baked feature to me.
How to add custom condition to Azure DevOps task which is actually a Task Group?
Sorry for any inconvenience.
Indeed, this issue is already tracked on Github and Developer Community:
https://github.com/microsoft/azure-pipelines-tasks/issues/5112
https://developercommunity.visualstudio.com/idea/362353/implement-conditions-for-task-groups.html
And I checked the internal channel, found that it has been converted as part of an engineer's request. But, since the backlog for the next 2 months is full. MS team will try to pick up task group conditions feature after that. Currently this request is in a low priority.
As workaround, we could add the custom condition to each tasks in the task group, which is the workaround we are currently using. But you said it is not even a workaround. If you have any other issue with this workaround? You can share it in your question, so that we can check if we could find other better workaround.
Hope this helps.
It is indeed possible to make this work with classic (non-YAML) pipelines. The trick is to use a PowerShell task as the first task in your task group, and within that task, set the value of a task variable. That task variable can then be used in the custom condition for other tasks in the group. e.g.
In the task group, create a PowerShell task as the first task with the following inline script:
if ($ExecutionContext.InvokeCommand.ExpandString($(customCondition))) {
Write-Host "evaluatedCustomCondition=true"
Write-Host "##vso[task.setvariable variable=evaluatedCustomCondition]true"
} else {
Write-Host "evaluatedCustomCondition=false"
Write-Host "##vso[task.setvariable variable=evaluatedCustomCondition]false"
}
Then, in the custom condition for each subsequent task in the task group:
and(succeeded(), eq(variables['evaluatedCustomCondition'], 'true'))
Then simply set the customCondition parameter value accordingly from the calling task, e.g.
'$(executeStep)' -eq 'true'
Please note that the customCondition value you're passing here should be in PowerShell syntax, and not the bespoke custom condition syntax (since it's going to be evaluated in PowerShell).
I have some Celery tasks and I'm checking their states periodically from a separate process by instantiating an AsyncResult using the task id.
From this, I get the task state. By implementing a custom results backend and extended AsyncResult class as described here, I'm able to also get the task name too. However, I want able to get a custom display name for each task - something human readable so that I can display the state info in a user friendly way.
Hypothetically, it might be set something like:
#app.task()
def my_task(args):
display_name = "My Task"
...
...
Then later I would do...
result = ExtendedAsyncResult(task_id)
result.display_name
But from looking at the custom results backend I linked to, there doesn't appear to be any way to access the local variables of the task.
Is there a way to achieve what I'm looking for?
Celery support task name - hope this is what you are looking for:
#app.task(name='My Task')
def my_task(args):
...
...
the My Task will now appear wherever you want (in flower for example).
I create a workflow, and when I go to the task-edit page:
I'm trying to obtain the nodeRef of the file (latexexemplo-2.pdf) of the workflow task:
http://localhost:8080/share/page/task-edit?taskId=activiti$20649
I'm trying to make this way:
var taskId = args.taskId
var task = workflow.getTaskById(taskId);
nodeRef = task.getPackageResources()[0].nodeRef;
But I obtain "args is not defined" ... "workflow is not defined" ... "task is not defined".
How can I get the nodeRef with another way?
Unfortunately, you cannot access in the browser information that is in the repository.
A quick and dirty solution is to use directly the information that is already in the page.
I have started a workflow and opened the task page as you did.
Using the browser debug tool, I have inspected the html.
As you can see in the image attached below, Alfresco stores the documents attached to the task in an hidden input. You could use YAHOO to get it.
Search for an element with the id "page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems".
If there is more than one document associated, the value will be a comma separated list of noderefs. I am getting the first element. This of course works, as is, only if there is one and only one document associated. You should probably take into account also the case when no document is associated or there is more than one.
var nodeRef = YAHOO.util.Selector.query("#page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems")[0].value;
You can get all the current task details which are assigned to you by using
Workflow API in Freemarker.
So you can get the task id or noderef of tasks.
I need pass data of a task1 (form of task1) to other task (form of task2), and see this data in the form of task2. I use one aspect for this and I have the next code (a part) for the taskListener (event: complete) in task1:
execution.setVariable('wf_data1', task.getVariable('wf_data1'));
In my task2, in the share-config-custom.xml, I have the wf_data1 in the form, but this shows empty.
Why happen this? How to see the wf_data1 in task2?
UPDATE:
The reason of why this not working is which in the file service-context.xml, the redeploy key is "false". I changed this to "true" and all is working.
Greetings,
Arak.
I'm not going to dive into your model and ways of showing it. Alfresco keeps track of the workflow history. I'm not sure till what detail(with/without aspects) is available, but it's quite easy to find out.
With this you can access workflow data in a next task. Just create a custom workflow form controller which retrieves data.