cancel
Showing results for 
Search instead for 
Did you mean: 

REST api - How to find node id associated with a task

sar_pooja
Champ in-the-making
Champ in-the-making
I am retrieving a list of review tasks using REST api - alfresco/service/api/task-instances
In the response I get details of the task instance. How can I get node id associated with the task instance using REST api?
3 REPLIES 3

lementree
Champ on-the-rise
Champ on-the-rise
Hi,

You cann't get the the node-id in direct.
In alfresco/service/api/task-instances api you will get

{
  "data": [
    {
      "id": "activiti$21817",
      "url": "api\/task-instances\/activiti$21817",
      "name": "inwf:acceptInviteTask",
      "title": "Site Invitation Accepted",
      "description": "The user invited to join the site has accepted the invitation",
      "state": "IN_PROGRESS",
      "path": "api\/workflow-paths\/activiti$21713",
      "isPooled": false,
      "isEditable": true,
      "isReassignable": false,
      "isClaimable": false,
      "isReleasable": false,
      "outcome": null,
      "owner": {
        "userName": "admin",
        "firstName": "Administrator",
        "lastName": "admin"
      },
      "properties": {
        "bpm_dueDate": null,
        "bpm_description": "Invitation to join iTOMS site",
        "bpm_status": "Not Yet Started",
        "bpm_priority": 2
      },
      "propertyLabels": {
        "bpm_priority": "Medium",
        "bpm_status": "Not Yet Started"
      },
      "workflowInstance": {
        "id": "activiti$21713",
        "url": "api\/workflow-instances\/activiti$21713",
        "name": "activiti$activitiInvitationNominated",
        "title": "Site Invitation - Nominated",
        "description": "Invitation to a Share Site, nominated by a site manager",
        "isActive": true,
        "startDate": "2012-09-28T15:25:06.869+05:30",
        "priority": 2,
        "message": "Invitation to join iTOMS site",
        "endDate": null,
        "dueDate": null,
        "context": null,
        "package": "workspace:\/\/SpacesStore\/da2dd29f-50a9-4728-8045-eb845a2af7a1",
        "initiator": {
          "userName": "admin",
          "firstName": "Administrator",
          "lastName": "admin"
        },
        "definitionUrl": "api\/workflow-definitions\/activiti$activitiInvitationNominated:1:26"
      }
    }
  ],
  "paging": {
    "maxItems": 50,
    "skipCount": 0,
    "totalItems": 1,
    "totalItemsRangeEnd": null,
    "confidence": "exact"
  }
}

using workflowInstance package's Noderef you can get the childrens of that workflow package, by using below url
alfresco/service/api/node/workspace/SpacesStore/da2dd29f-50a9-4728-8045-eb845a2af7a1/children

hita
Champ in-the-making
Champ in-the-making
Hi lementree,
I've try to get the data of the task instance with: /alfresco/service/api/task-instances/taskID
And it return:

{
  "data": {
    "id": "activiti$445",
    "url": "api/task-instances/activiti$445",
    "name": "wf:adhocTask",
    "title": "Task",
    "description": "Task allocated by colleague",
    "state": "IN_PROGRESS",
    "path": "api/workflow-paths/activiti$401",
    "isPooled": false,
    "isEditable": true,
    "isReassignable": true,
    "isClaimable": false,
    "isReleasable": false,
    "outcome": null,
    "owner": {
      "userName": "admin",
      "firstName": "Administrator",
      "lastName": ""
    },
    "properties": {
      "bpm_percentComplete": 0,
      "bpm_description": "tada",
      "bpm_hiddenTransitions": [],
      "bpm_package": "workspace://SpacesStore/2b9786c5-7167-4084-818e-dfe957528de0",
      "bpm_dueDate": null,
      "bpm_context": null,
      "bpm_priority": 2,
      "bpm_taskId": "445",
      "bpm_reassignable": true,
      "bpm_startDate": "2014-08-28T02:36:05.804Z",
      "bpm_completedItems": null,
      "bpm_pooledActors": [],
      "bpm_status": "Not Yet Started",
      "bpm_comment": null,
      "bpm_completionDate": null,
      "bpm_packageActionGroup": "add_package_item_actions",
      "cm_content": null,
      "bpm_packageItemActionGroup": "edit_package_item_actions",
      "cm_created": "2014-08-28T02:36:05.804Z",
      "bpm_outcome": null,
      "cm_name": null,
      "cm_owner": "admin"
    },
    "propertyLabels": {
      "bpm_priority": "Medium",
      "bpm_status": "Not Yet Started"
    },
    "workflowInstance": {
      "id": "activiti$401",
      "url": "api/workflow-instances/activiti$401",
      "name": "activiti$activitiAdhoc",
      "title": "New Task",
      "description": "Assign a new task to yourself or a colleague",
      "isActive": true,
      "startDate": "2014-08-28T09:36:05.804+07:00",
      "priority": 2,
      "message": "tada",
      "endDate": null,
      "dueDate": null,
      "context": null,
      "package": "workspace://SpacesStore/2b9786c5-7167-4084-818e-dfe957528de0",
      "initiator": {
        "userName": "admin",
        "firstName": "Administrator",
        "lastName": ""
      },
      "definitionUrl": "api/workflow-definitions/activiti$activitiAdhoc:1:4"
    },
    "definition": {
      "id": "wf:adhocTask",
      "url": "api/task-definitions/wf:adhocTask",
      "type": {
        "name": "wf:adhocTask",
        "title": "Task",
        "description": "Task allocated by colleague",
        "url": "api/classes/wf_adhocTask"
      },
      "node": {
        "name": "adhocTask",
        "title": "Adhoc Task",
        "description": "adhocTask",
        "isTaskNode": true,
        "transitions": [
          {
            "id": "Next",
            "title": "Task Done",
            "description": "Task Done",
            "isDefault": true,
            "isHidden": false
          }
        ]
      }
    }
  }
}


I'm pretty sure that I already associate my item to this workflow. But the workflow package is empty.
Below is my task detail screen.
Please help me if you are still in this post.
Thanks in advance.

shadow4110
Champ in-the-making
Champ in-the-making
hi Hita,
i had the same problem. but have used another URL for getting the attached resources to workflow i.e.
<a href="http://localhost:8080/alfresco/service/slingshot/dashlets/my-tasks">http://localhost:8080/alfresco/service/slingshot/dashlets/my-tasks</a>
this webscript return the list of my task. here is an example of responce


{
   "tasks":
   [
   {
      "id": "activiti$2449",
      "description": "testing wf",
      "dueDate": "2015-02-12 00:00:00 GMT+0530 (IST)",
      "status": "Not Yet Started",
      "priority": "2",
      "startDate": "2015-02-10 22:17:24 GMT+0530 (IST)",
      "type": "New Task",
      "completeness": "0",
      "resources":
      [
         {
            "nodeRef": "workspace://SpacesStore/459344e0-3855-4962-b902-b3c31cb94a2a",
            "fileName": "test.pdf",
            "displayName": "test.pdf",
            "location":
            {
            },
            "icon": "/images/filetypes/pdf.gif"
         }
      ],
      "transitions":
      [
         {
            "id": "Next",
            "label": "Task Done"
         }
      ]
   }
   ,
   {
      "id": "activiti$2544",
      "description": "Adhoc task",
      "dueDate": "2015-02-12 00:00:00 GMT+0530 (IST)",
      "status": "Not Yet Started",
      "priority": "2",
      "startDate": "2015-02-10 23:06:00 GMT+0530 (IST)",
      "type": "review task",
      "completeness": "0",
      "resources":
      [
         {
            "nodeRef": "workspace://SpacesStore/459344e0-3855-4962-b902-b3c31cb94a2a",
            "fileName": "test.pdf",
            "displayName": "test.pdf",
            "location":
            {
            },
            "icon": "/images/filetypes/pdf.gif"
         }
      ],
      "transitions":
      [
         {
            "id": "Next",
            "label": "Task Done"
         }
      ]
   }
  ]
}