<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to filter /tasks REST API output to show only assigned tasks? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127807#M34700</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My first query here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to retrieve tasks assigned to the logged in user. The initial plan was to use GET /tasks API.&lt;/P&gt;&lt;P&gt;However ,after testing for some scenarios, I understood that the API returns tasks if the logged in user is the creator of the process too.&lt;/P&gt;&lt;P&gt;API documentation(on API-Explorer) is not clear on this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Gets a list of tasks visible to the authenticated user.&lt;/P&gt;&lt;P&gt;Tasks are returned for which the authenticated user is the &lt;STRONG&gt;assignee or&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;a candidate....&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;My query is how do i filter the response to retrieve only the assigned or candidate tasks? ( i.e. to avoid the&amp;nbsp; unassigned tasks from the processes created by logged in user)&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Viresh&lt;/P&gt;&lt;P&gt;P.S.: I usually find answers on this forum or via code on github but for this query couldn't find enough info.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Edit 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My quick fix idea ,as of now, is to use GET /tasks/{taskId}/candidates&amp;nbsp; API respone to check if the logged in user is one of the candidates.&amp;nbsp; &amp;nbsp;As the current scenarios ,doesn't invlove groups, this should be sufficient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But was wondering if there's a better way. Also wonder if the API documentation is incomplete ,if not incorrect.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Feb 2022 15:45:57 GMT</pubDate>
    <dc:creator>sheriv</dc:creator>
    <dc:date>2022-02-01T15:45:57Z</dc:date>
    <item>
      <title>How to filter /tasks REST API output to show only assigned tasks?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127807#M34700</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;My first query here.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to retrieve tasks assigned to the logged in user. The initial plan was to use GET /tasks API.&lt;/P&gt;&lt;P&gt;However ,after testing for some scenarios, I understood that the API returns tasks if the logged in user is the creator of the process too.&lt;/P&gt;&lt;P&gt;API documentation(on API-Explorer) is not clear on this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Gets a list of tasks visible to the authenticated user.&lt;/P&gt;&lt;P&gt;Tasks are returned for which the authenticated user is the &lt;STRONG&gt;assignee or&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;a candidate....&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;My query is how do i filter the response to retrieve only the assigned or candidate tasks? ( i.e. to avoid the&amp;nbsp; unassigned tasks from the processes created by logged in user)&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Viresh&lt;/P&gt;&lt;P&gt;P.S.: I usually find answers on this forum or via code on github but for this query couldn't find enough info.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Edit 1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;My quick fix idea ,as of now, is to use GET /tasks/{taskId}/candidates&amp;nbsp; API respone to check if the logged in user is one of the candidates.&amp;nbsp; &amp;nbsp;As the current scenarios ,doesn't invlove groups, this should be sufficient.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But was wondering if there's a better way. Also wonder if the API documentation is incomplete ,if not incorrect.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 15:45:57 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127807#M34700</guid>
      <dc:creator>sheriv</dc:creator>
      <dc:date>2022-02-01T15:45:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter /tasks REST API output to show only assigned tasks?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127808#M34701</link>
      <description>&lt;P&gt;Not sure if I understand your question...&lt;/P&gt;
&lt;P&gt;I created a workflow with "admin" user and assigned a task to "test" user.&lt;/P&gt;
&lt;P&gt;When executing following invocation from with user "test" authenticated...&lt;/P&gt;
&lt;PRE&gt;curl -X GET "http://127.0.0.1:8080/alfresco/api/-default-/public/workflow/versions/1/tasks" -H  "accept: application/json"&lt;/PRE&gt;
&lt;P&gt;... I'm getting this result.&lt;/P&gt;
&lt;PRE&gt;"entries": [
      {
        "entry": {
          "processDefinitionId": "activitiAdhoc:1:4",
          "processId": "167",
          "name": "Adhoc Task",
          "description": "Adhoc Task",
          "startedAt": "2022-02-01T16:37:21.504+0000",
          "id": "213",
          "assignee": "test",
          "state": "claimed",
          "activityDefinitionId": "adhocTask",
          "priority": 2,
          "formResourceKey": "wf:adhocTask"
        }
      }
    ]&lt;/PRE&gt;
&lt;P&gt;That seems expected to me.&lt;/P&gt;
&lt;P&gt;What should be the response of this request?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Feb 2022 16:40:26 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127808#M34701</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2022-02-01T16:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter /tasks REST API output to show only assigned tasks?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127809#M34702</link>
      <description>&lt;P&gt;hi angelborroy,&lt;/P&gt;&lt;P&gt;Thank you for the quick response.&lt;/P&gt;&lt;P&gt;It's my mistake that i did not describe the scenario completely.&lt;/P&gt;&lt;P&gt;I have created a custom workflow by following jeffpotts's tutorial.&amp;nbsp;&lt;/P&gt;&lt;P&gt;for simplicity let's say the workflow has 4 tasks assigned to testuser1 to 4&amp;nbsp; respectively i.e.&lt;/P&gt;&lt;P&gt;task1--&amp;gt;candidateusers: testuser1&lt;/P&gt;&lt;P&gt;task2--&amp;gt;candidateusers: testuser2&lt;/P&gt;&lt;P&gt;task3--&amp;gt;candidateusers: testuser3&lt;/P&gt;&lt;P&gt;task4--&amp;gt;candidateusers: testuser4&lt;/P&gt;&lt;P&gt;Note: i am using activiti:candidateusers to make the tasks pooled one.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now ,coming to my issue, the scenario is as below.&lt;/P&gt;&lt;P&gt;testuser4&amp;nbsp; creates the process.&lt;/P&gt;&lt;P&gt;testuser1 being candidate for task1 is a potential candiate.&lt;/P&gt;&lt;P&gt;My expected API response in this case is&amp;nbsp;&lt;/P&gt;&lt;P&gt;for testuser1:&amp;nbsp; response should have&amp;nbsp; task1 entry.&lt;/P&gt;&lt;P&gt;for testuser4: response should not have any entry.&lt;/P&gt;&lt;P&gt;current API behavior:&lt;/P&gt;&lt;P&gt;for testuser1:&amp;nbsp; response&amp;nbsp; has&amp;nbsp; task1 entry.&lt;/P&gt;&lt;P&gt;for testuser4: response &lt;STRONG&gt;has&lt;/STRONG&gt; task1 entry.&lt;/P&gt;&lt;P&gt;I presume testuser4 being the creator of the process is able to view task1 entry even though he/she is not assigned with that task neither is he/she a candidate user.&lt;/P&gt;&lt;P&gt;But for me, if i have to show list of assigned tasks,&amp;nbsp; i should know if the task entry in response is because it's assigned to me or because i was the process creator.&lt;/P&gt;&lt;P&gt;My query was how to differentiate the task entries in the response along this?&lt;/P&gt;&lt;P&gt;Hope this helps in simplification of my query.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Viresh&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 04:11:55 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127809#M34702</guid>
      <dc:creator>sheriv</dc:creator>
      <dc:date>2022-02-02T04:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter /tasks REST API output to show only assigned tasks?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127810#M34703</link>
      <description>&lt;P&gt;You may try filtering by &lt;STRONG&gt;assignee &lt;/STRONG&gt;(user "test" in the following sample):&lt;/P&gt;
&lt;PRE class="microlight" style="box-sizing: border-box; font-family: monospace; font-size: 12px; margin: 0px; padding: 10px; white-space: pre-wrap; word-break: break-word; hyphens: auto; border-radius: 4px; background: #333333; overflow-wrap: break-word; font-weight: 600; color: #ffffff; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"&gt;http://127.0.0.1:8080/alfresco/api/-default-/public/workflow/versions/1/tasks?where=(assignee%3Dtest)&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Feb 2022 09:19:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127810#M34703</guid>
      <dc:creator>angelborroy</dc:creator>
      <dc:date>2022-02-02T09:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter /tasks REST API output to show only assigned tasks?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127811#M34704</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I tried the api with whee clause in api-explorer.&lt;/P&gt;&lt;P&gt;I think the assignee is not set in the response entry if the task is a pooled one. And thus /tasks will not return the pooled tasks in the return if i use where clause.&lt;/P&gt;&lt;P&gt;Following are the responses for test user "tu1":&lt;/P&gt;&lt;P&gt;Without where clause:&lt;/P&gt;&lt;PRE&gt;curl -X GET "http://&amp;lt;ip&amp;gt;:8080/alfresco/api/-default-/public/workflow/versions/1/tasks" -H "accept: application/json" -H "authorization: Basic dHUxOnR1MQ=="&lt;/PRE&gt;&lt;P&gt;response:&lt;/P&gt;&lt;PRE&gt;{
  "list": {
    "pagination": {
      "count": 4,
      "hasMoreItems": false,
      "totalItems": 4,
      "skipCount": 0,
      "maxItems": 100
    },
    "entries": [
      {
        "entry": {
          "processDefinitionId": "myWF:24:5308",
          "processId": "5757",
          "name": "myReview1",
          "description": "myReview1",
          "startedAt": "2022-02-01T13:10:07.969+0000",
          "id": "5933",
          "state": "unclaimed",
          "activityDefinitionId": "usertask5",
          "priority": 2,
          "formResourceKey": "mywf:myReview1Task"
        }
      },
      {
        "entry": {
          "processDefinitionId": "mywf:24:5308",
          "processId": "5965",
          "name": "myReview1",
          "description": "TEST tu2 assignments",
          "startedAt": "2022-02-01T13:19:28.653+0000",
          "id": "6044",
          "state": "unclaimed",
          "activityDefinitionId": "usertask3",
          "priority": 2,
          "formResourceKey": "mywf:myReview1Task"
        }
      },
      {
        "entry": {
          "processDefinitionId": "mywf:24:5308",
          "processId": "6575",
          "name": "myReview1",
          "description": "myReview1",
          "startedAt": "2022-02-02T11:37:35.027+0000",
          "id": "6652",
          "state": "unclaimed",
          "activityDefinitionId": "usertask3",
          "priority": 2,
          "formResourceKey": "mywf:myReview1Task"
        }
      },
      {
        "entry": {
          "processDefinitionId": "mywf:24:5308",
          "processId": "6695",
          "name": "myReview1",
          "description": "myReview1",
          "startedAt": "2022-02-02T11:39:26.222+0000",
          "id": "6772",
          "state": "unclaimed",
          "activityDefinitionId": "usertask3",
          "priority": 2,
          "formResourceKey": "mywf:myReview1Task"
        }
      }
    ]
  }
}&lt;/PRE&gt;&lt;P&gt;with where clause:&lt;/P&gt;&lt;PRE&gt;curl -X GET "http://&amp;lt;ip&amp;gt;:8080/alfresco/api/-default-/public/workflow/versions/1/tasks?where=(assignee%3Dtu1)" -H  "accept: application/json" -H  "authorization: Basic dHUxOnR1MQ=="&lt;/PRE&gt;&lt;P&gt;response:&lt;/P&gt;&lt;PRE&gt;{
  "list": {
    "pagination": {
      "count": 0,
      "hasMoreItems": false,
      "totalItems": 0,
      "skipCount": 0,
      "maxItems": 100
    },
    "entries": []
  }
}&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;My updated quick fix is as below:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;get all the pooled tasks:&amp;nbsp; filter it by using&amp;nbsp; response of /tasks/&amp;lt;taskId&amp;gt;/candidates.&amp;nbsp; --&amp;gt;this will cover cases where the bpmn task assignment is done via&amp;nbsp; activiti:candidateusers.&lt;/P&gt;&lt;P&gt;get all the assigned tasks: using where clause for assignee -------&amp;gt;this will be useful for tasks where assignment is direct such as {initiator.user.name}&lt;/P&gt;&lt;P&gt;Please let me know if there's a better way to handle this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also it would be very much helpful for me if you could point me to github source location which shows how shareUI does it for "My tasks" listing.&lt;/P&gt;&lt;P&gt;(i did search for it but as I am relatively new with alfresco, couldn't find the exact source and/or ftl file for tasks listing)&lt;/P&gt;&lt;P&gt;thank you.&lt;/P&gt;&lt;P&gt;viresh&lt;/P&gt;</description>
      <pubDate>Wed, 02 Feb 2022 12:01:58 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-filter-tasks-rest-api-output-to-show-only-assigned-tasks/m-p/127811#M34704</guid>
      <dc:creator>sheriv</dc:creator>
      <dc:date>2022-02-02T12:01:58Z</dc:date>
    </item>
  </channel>
</rss>

