Get task by code

  • 1
  • Question
  • Updated 3 years ago
  • Answered
In Gen2, the API had a method to retrieve a task (and the project associated with that task) by specifying the code (eg ABC1.0).  I cannot find a way to do this in Gen3 other than to retrieve all projects, iterate over each one and retrieve all of the tasks for those projects, then iterate over everything attempting to match the code to part of the displayText field.  There has to be a better way to do this?
Photo of Joe Constant

Joe Constant

  • 4 Posts
  • 0 Reply Likes

Posted 3 years ago

  • 1
Photo of Lingaraj Dharwad

Lingaraj Dharwad, Product Champion

  • 1100 Posts
  • 46 Reply Likes
Hi Joe,

Thank you for using Replicon community,

We are checking this with the concerned team and will respond by EOD today. 

Thanks,
Lingaraj
Photo of Gautham Amalakumar

Gautham Amalakumar, Tier 3 Engineer

  • 7 Posts
  • 3 Reply Likes
Hi Joe,

 

Yes, we do have an option to get the Tasks based on codes.

Instead of using the TaskService1 you can use the “TaskListService1.svc/GetData” and use the Text Search option to search with the Task Code.


Here is an example of the Service call.

{

  "page": "1",

  "pagesize": "100000",

  "columnUris": [

    "urn:replicon:task-list-column:task",

    "urn:replicon:task-list-column:code",

    "urn:replicon:task-list-column:full-path"

  ],

  "sort": [],

  "filterExpression": {

    "leftExpression": {

      "leftExpression": null,

      "operatorUri": null,

      "rightExpression": null,

      "value": null,

      "filterDefinitionUri": "urn:replicon:task-list-filter:text"

    },

    "operatorUri": "urn:replicon:filter-operator:text-search",

    "rightExpression": {

      "leftExpression": null,

      "operatorUri": null,

      "rightExpression": null,

      "value": {

        "uri": null,

        "uris": [],

        "bool": null,

        "date": null,

        "money": null,

        "number": null,

        "text": "TSKCODE1000",

        "time": null,

        "calendarDayDurationValue": null,

        "workdayDurationValue": null,

        "dateRange": null

      },

      "filterDefinitionUri": null

    },

    "value": null,

    "filterDefinitionUri": null

  }

}

 

If you perform the above value as the input for the service call then you will get the tasks which has the respective Task Code Tasks as the result.

 

The Available columns which can be used are available using the service “TaskListService1.svc/GetAllColumns”.

 

Photo of Joe Constant

Joe Constant

  • 4 Posts
  • 0 Reply Likes
When I try running that from services/help/all screens, I get the below error:


403 Forbidden
Date: Tue, 03 Nov 2015 18:04:40 GMT
Cache-Control: private
Connection: close
Content-Length: 462
X-Execution-Correlation-Id: 3d223abd4ff045ddacaa8d11d956aea2
Content-Type: application/json; charset=utf-8

{"error":{"code":"Sender","correlationId":"3d223abd4ff045ddacaa8d11d956aea2","reason":"All access checks failed to authorize operation 'GetData' : The following permissions are required: Action(urn:replicon:list-service-dynamic-permission:view)","details":{"displayText":"All access checks failed to authorize operation 'GetData' : The following permissions are required: Action(urn:replicon:list-service-dynamic-permission:view)"},"type":"AuthorizationError1"}}
Photo of Lingaraj Dharwad

Lingaraj Dharwad, Product Champion

  • 1100 Posts
  • 46 Reply Likes
Hi Joe,

Your profile needs to be assigned a project management permission with View 'All Projects' & 'All Tasks' as shown in the screenshots below: 

Screenshot of Project Manager permission:



Screenshot of the user profile page:



This will allow you to run the above query.

Thanks,
Lingaraj
Photo of Joe Constant

Joe Constant

  • 4 Posts
  • 0 Reply Likes
That's not going to work.  Especially the edit permissions.  We only want people to see projects/tasks they are assigned to.  Why would the API require a user to be able to see all projects and tasks in order to pull the details for a single task.  Your search filter should be able to search for only "visible" tasks to the user
Photo of Lingaraj Dharwad

Lingaraj Dharwad, Product Champion

  • 1100 Posts
  • 46 Reply Likes
Hi Joe,

If you enable 'view' permission under my projects section, then the user will only be able to query their own projects where they are assigned as the project manager. 

'View' permission for all projects will be needed if the user needs to query other projects where they are not set up as project managers. Edit permission is not mandatory. 

Hope that answers your question.

Thanks,
Lingaraj
Photo of Laurent, Tim

Laurent, Tim

  • 1 Post
  • 0 Reply Likes
Hi Lingaraj,

Why do all employees need Project Manager access for this API? Doesn't that present a security issue? Why not based on the "User" permission?

Thanks,
Tim
Photo of Gautham Amalakumar

Gautham Amalakumar, Tier 3 Engineer

  • 7 Posts
  • 3 Reply Likes
Hi Tim,

I understand from your comment that providing Project Manager access just for accessing API can cause a security issue. However, my colleague Lingaraj's explanation was for Project Managers only and not for End Users.

Please follow my post below for information on achieving the same with End User Permission.
Photo of Gautham Amalakumar

Gautham Amalakumar, Tier 3 Engineer

  • 7 Posts
  • 3 Reply Likes
Based on your recent reply I understand that you are attempting to pull task information with end user permission. To achieve that please follow my suggestion below. My previous explanation holds good only if you are trying to pull Project/Task Info with Project Manager permission.

 

For an End User to get the Tasks assigned to him/her, you can search the task with code using the service “TimesheetService1.svc/GetPageOfTasksAvailableForTimeAllocationFilteredByProjectAndTextSearch”.

The Input for this service is

 

{

  "page": "1",

  "pageSize": "100000",

  "timesheetUri": "Timesheet URI",

  "projectUri": "Project URI",

  "textSearch": {

    "queryText": "1000",

    "searchInDisplayText": "false",

    "searchInFullPathDisplayText": "false",

    "searchInName": "false",

    "searchInDescription": "false",

    "searchInCode": "true"

  }

}

 

An End User can retrieve the Project URIs from the instance using the following service “TimesheetService1.svc/help/test/GetPageOfProjectsAvailableForTimeAllocationFilteredByClientAndTextSearch”.

 

Photo of Joe Constant

Joe Constant

  • 4 Posts
  • 0 Reply Likes
So that still requires multiple API calls where the Gen2 API only required one.  Gen2 has a call like this:

{
    'Action': 'Query',
    'QueryType': 'TaskByCode',
    'DomainType': 'Replicon.Project.Domain.Task',
    'Args': {
        '1000'
     }
}

Whereas it now seems that Gen3 requires a call to search for a project by name, iterate through the results to verify you had a direct match.  Then another search for tasks in a project (and I don't get the need for the timesheetURN in all of these calls when you aren't actually searching the timesheet). Why is there no matching call for TaskByCode in Gen3?
Photo of Lingaraj Dharwad

Lingaraj Dharwad, Product Champion

  • 1100 Posts
  • 46 Reply Likes
Hi Joe,

We are waiting for further details on this from the PM team. We are sorry for the delay in replying.

Thanks,
Lingaraj