Task objects represent a user-created task on a file.
- Get a Task's Information
- Get the Tasks on a File
- Add a Task to a File
- Update a Task's Information
- Delete a Task
- Get a Task's Assignments
- Get Information About a Task Assignment
- Add a Task Assignment
- Delete a Task Assignment
- Update a Task Assignment
Calling getInfo()
on a task returns a snapshot of the task's
info.
BoxTask task = new BoxTask(api, "id");
BoxTask.Info info = task.getInfo();
You can get all of the tasks on a file by calling the
getTasks()
method.
BoxFile file = new BoxFile(api, "id");
List<BoxTask.Info> tasks = file.getTasks();
A task can be added to a file with the
addTask(String taskType, String message, Date dueDate)
method.
BoxFile file = new BoxFile(api, "id");
Date dueAt = new Date();
file.addTask("review", "Please review this file.", dueAt);
The message of a task can be changed with the
updateInfo(BoxTask.Info fieldsToUpdate)
method.
BoxTask task = new BoxTask(api, "id");
BoxTask.Info info = task.new Info();
info.setMessage("An edited message.");
task.updateInfo(info);
A task can be deleted with the delete()
method.
BoxTask task = new BoxTask(api, "id");
task.delete();
Retreive a tasks assignments with the getAssignments()
method.
BoxTask task = new BoxTask(api, "id");
task.getAssignments();
To look up information about a task assignment by its ID, instantiate the
BoxTaskAssignment
object with the ID, and call getInfo()
on the assignment. To retrieve only specific fields on the task assignment, call
getInfo(String... fields)
with the fields to retrieve.
String assignmentID = "4256974";
BoxTaskAssignment.Info assignmentInfo = new BoxTaskAssignment(api, assignmentID).getInfo();
An assignment can be added to a task with the
addAssignment(BoxUser assignee)
method.
BoxUser user = new BoxUser(api, "user-id")
BoxTask task = new BoxTask(api, "id");
task.addAssignment(user);
An assignment can be deleted from a task with the
delete()
method on a BoxTaskAssignment
instance.
BoxTaskAssignment taskAssignment = new BoxTaskAssignment(api, "id");
taskAssignment.delete();
A task assignment can be updated with the
updateInfo(BoxTask.Info fieldsToUpdate)
method.
String assignmentID = "12345";
BoxTaskAssignment taskAssignment = new BoxTaskAssignment(api, assignmentID);
BoxTaskAssignment.Info info = taskAssignment.getInfo();
info.addPendingChange("resolution_state", "approved");
taskAssignment.updateInfo(info);