How to get a person assigned to the task in Alfresco? - workflow

There are many elements in repo and I start workflows specifying a document attached to the workflow:
var workflow = actions.create("start-workflow");
// ...
var node = search.findNode("workspace://SpacesStore/" + uuid);
workflow.execute(node);
Workflow starts so I can see it in my-tasks page.
Then I want to receive an active task from the workflow and a list of people who works due to this task. Is it possible? Moreover I want to get a list of people assigned to the workflow at all.
But this is not all! I want to receive custom properties defined in the workflow model, but I don't see anything like properties field or methods to get property in the WorkflowInstance.
I'm sure that I just don't undestand something, so explain me please: how can I do everything I asked?

Related

How to reset VSTS counter?

We have a need to reset VSTS counter. I do not see any way to do this through UI. There is a way to do it by directly invoking reset build counter REST API, but in order to do this, you need to know the counter id, which you should be able to find out by invoking get a definition REST API. Unfortunately, no matter what I do get a definition call does not return build definition counter.
What am I missing?
Scott Dallamura from Microsoft wrote this thread:
the counters feature was experimental and removed back in March of
this year. I'm not sure how it even got into the documentation, but
I'll make sure it gets cleaned up.
I also didn't success to get the counterId in an API call.
At workaround, you can reset the revision of the build number if you change the build definition name, you can just add/remove a character.
Instead of trying to reset the counter variable, you could create a new variable with a GUID prefix.
This solution creates duplicate counters which might not be ideal but this gives you the ability to revert back to the previous counter values, if necessary.
Please see the following YAML code snippet
variables:
...
#Change this Guid if you require a reset seed on the same value.
resetCounterGuid: 'efa9f3f5-57fb-4254-8a7a-06d5bb365173'
buildrevision: $[counter(format('{0}\\{1}',variables['resetCounterGuid'],variables['YOUR_DEFINED_VARIABLE']),0)]
...

Celery task display name

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).

Get NodeRef of a workflow task Alfresco

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.

Alfresco: How to see the data of a finished task in the next task?

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.

TeamCity REST API get list of pending changes

Is there a REST API endpoint to get a collection of changes that are pending for a build in TeamCity?
We have the build set to manual and it is triggered outside TeamCity and would like to show a bullet point list of commits that'd be in that build.
In the user interface you can see this under the "Pending Changes (X)" tab.
I can't find any examples of doing this and the closest I've found is:
http://<server>/httpAuth/app/rest/changes/buildType:<build type id>
This seems to return the last change though.
Anyone done this before?
I just found a working solution thanks to this question. I'll show it here in case other people are looking for a full solution :
You need to know the buildTypeId of the build on which you want to get the pending changes. In this case lets say buildTypeId=bt85
1
http://<server>/httpAuth/app/rest/buildTypes/id:bt85/builds/
// Get the last build from the XML returned.
// Lets say last build id = 14000
2
http://<server>/httpAuth/app/rest/changes?build=id:14000
// The newest change returned is the one you need.
// Lets say newest change id = 15000
3
http://<server>/httpAuth/app/rest/changes?buildType=id:bt85&sinceChange=15000
// You're now looking at the pending changes list of the buildType bt85
My eventual solution in a work around kind of way is to:
Find the latest change ID from my database of builds outside of TeamCity (I guess you could query the TeamCity API to find the last successful build and pull it from there)
Then call:
http://<server>/httpAuth/app/rest/changes?buildId=id:<build id>&sinceChange=id:<last change id>
Then fetch each individual change from that list.
A bit of a workaround but I couldn't see anyway otherwise to get the list of pending changes.