Does task exist

I have a process model that cancel a task.  I am getting an error email stating that the task to cancel does not exist.  We should not experience this in our production environment since we check to see if a task has been completed. In our test environment we routinely clean up our task to prevent clutter. So, we have experienced this on occasion.  UIs there a way to check to see if a task exists before trying to cancel it using the smart service?  I was hoping there was a function or some query I could run.

  Discussion posts and replies are publicly visible

Parents
  • I'd suggest creating a task report that you can query from that includes all tasks and a column for the task ID. You can add a filter to your query to only return a task with the given ID. Then, if no tasks are returned, then the task doesn't exist. Here's a sample query that you can run against your task report:

    a!queryProcessAnalytics(
      report: cons!MY_TASK_REPORT,
      query: a!query(
        filter: a!queryFilter(
          field: <your ID column here>,
          operator: "=",
          value: ri!taskId
        ),
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 1
        )
      )
    )

    I'd also suggest reviewing the Task Report Tutorial

Reply
  • I'd suggest creating a task report that you can query from that includes all tasks and a column for the task ID. You can add a filter to your query to only return a task with the given ID. Then, if no tasks are returned, then the task doesn't exist. Here's a sample query that you can run against your task report:

    a!queryProcessAnalytics(
      report: cons!MY_TASK_REPORT,
      query: a!query(
        filter: a!queryFilter(
          field: <your ID column here>,
          operator: "=",
          value: ri!taskId
        ),
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 1
        )
      )
    )

    I'd also suggest reviewing the Task Report Tutorial

Children