How to configure Task action for a Granite Task | Community
Skip to main content
April 10, 2017
Solved

How to configure Task action for a Granite Task

  • April 10, 2017
  • 5 replies
  • 1987 views

For a Granite Task, I can see setAction() and getAction() methods which sets and gets action-id. But I don't know how to tell what action is to be done for certain action-id.

How can we configure the action for an action-id?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by vjetty

Hi, Rahujai

You may do something like the example in the following

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/adobe/acs/samples/taskmanagement/impl/SampleTaskManagementImpl.java

First get your task using task manager and then get the status of the task. There you can write your code according to your requirement if the task status is giving complete. Just go through property listener as well. 

Thanks,

Vamsi

5 replies

vjetty
Level 4
April 11, 2017

Hi, Rahujai

Here is the API you need to use for achieving your requirements. 

https://docs.adobe.com/docs/en/aem/6-0/develop/ref/javadoc/com/adobe/granite/taskmanagement/class-use/TaskManagerException.html

It has following methods you can use of....

void    TaskManager.completeTask(String taskId, String actionId) Completes the task with the given id and action. Task TaskManager.createTask(String parentTaskId, Task task) Creates a subtask under the specified parentTaskid Task TaskManager.createTask(Task task) Creates a task. void TaskManager.deleteTask(String taskId) Deletes the task with the given task ID. Task TaskManager.getTask(String taskId) Retrieves a fully populated task instance for the given task id. Task TaskManager.getTask(String taskId, boolean retrieveSubTasks) Retrieves the task identified by taskId and opotionally retrieves the task's subtasks. Iterator<Task> TaskManager.getTasks(Filter filter) Same as calling TaskManager.getTasks(Filter, int, int) with startIndex of 0, and length of -1 Used as a convenience for calls that do not need to limit the number of tasks being returned Iterator<Task> TaskManager.getTasks(Filter filter, int startIndex, int length) returns all tasks for the specified task type, or all tasks if no tasktype specified. Task TaskManagerFactory.newTask(String taskTypeName) Creates a new task instance with the given task type name. Task TaskManager.saveTask(Task task) Saves the given task instance. void TaskManager.terminateTask(String taskId) Terminates the task

Thanks,

Vamsi

MC_Stuff
Level 10
April 12, 2017

Hi rahujai,

  Use the default action. I have not seen any example how to define custom action & also product source itself always using default action.

Thanks,

MC_Stuff
Level 10
April 12, 2017

Hi rahujai,

  Use the default action. I have not seen any example how to define custom action & also product source itself always using default action.

Thanks,

April 12, 2017

MC Stuff wrote...

Hi rahujai,

  Use the default action. I have not seen any example how to define custom action & also product source itself always using default action.

Thanks,

 

 

Actually I want to trigger some code if someone completes the task. How can I achieve that?

vjetty
vjettyAccepted solution
Level 4
April 13, 2017

Hi, Rahujai

You may do something like the example in the following

https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/adobe/acs/samples/taskmanagement/impl/SampleTaskManagementImpl.java

First get your task using task manager and then get the status of the task. There you can write your code according to your requirement if the task status is giving complete. Just go through property listener as well. 

Thanks,

Vamsi