Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

How to configure Task action for a Granite Task

Avatar

Level 1

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?

1 Accepted Solution

Avatar

Correct answer by
Level 4

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/ad...

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

View solution in original post

5 Replies

Avatar

Level 4

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-us...

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

Avatar

Level 9

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,

Avatar

Level 9

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,

Avatar

Level 1

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?

Avatar

Correct answer by
Level 4

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/ad...

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