List
Represents a task list.
addEditor(userOrInvite)
Adds the given user to the editors of this list. Does nothing if the user is already in the list of editors.
Parameters
userOrInvite
The user or invite to add as an editor.
Return value
The updated List
.
addTask(name, parse)
Adds a new task to this list.
Parameters
name
The name of the new task. Cannot be empty or contain only whitespace.
parse
Optionaltrue
to use Smart Add to process the task name,false
otherwise.
Return value
The newly added Task
.
Example
// Adds a new task to Inbox.
const inbox = rtm.getInbox();
const task = inbox.addTask('Make dentist appointment ^today !1', true);
addViewer(userOrInvite)
Adds the given user to the viewers of this list. Does nothing if the user is already in the list of viewers.
Parameters
userOrInvite
The user or invite to add as a viewer.
Return value
The updated List
.
archive()
Archives the list.
Return value
The archived List
.
Example
// Archives "Renovation" list.
const renovationList = rtm.getLists()
.find(list => list.getName() === 'Renovation');
if (renovationList != null) {
renovationList.archive();
console.log('Archived "Renovation" list.');
} else {
console.log('"Renovation" list not found.');
}
delete()
Deletes the list. All incomplete and completed tasks in the list are moved to the Trash.
Return value
undefined
Example
// Deletes "Low Priority" list.
const lowPriorityList = rtm.getLists()
.find(list => list.getName() === 'Low Priority');
if (lowPriorityList != null) {
lowPriorityList.delete();
console.log('Deleted "Low Priority" list.');
} else {
console.log('"Low Priority" list not found.');
}
getCreatedDate()
Gets the date the list was created.
Return value
Example
// Outputs all lists and their created dates.
rtm.getLists().forEach(list =>
console.log("%s - %s", list.getName(), list.getCreatedDate()));
getEditors()
Gets the editors of the list.
Return value
The list of User
s and Invite
s who can edit this list.
getId()
Gets the ID of the list.
Return value
string
getModifiedDate()
Gets the date the list was last modified.
Return value
Example
// Outputs all lists and their modified dates.
rtm.getLists().forEach(list =>
console.log("%s - %s", list.getName(), list.getModifiedDate()));
getName()
Gets the name of the list.
Return value
The name of the List
.
Example
// Outputs all lists
rtm.getLists().forEach(list => console.log(list.getName()));
getPermalink()
Gets a permalink for this list.
Return value
String
Example
// Outputs all lists and their permalinks.
rtm.getLists().forEach(list =>
console.log("%s - %s", list.getName(), list.getPermalink()));
getTasks(filter)
Gets all tasks in this list.
Parameters
filter
OptionalIf specified, only tasks matching the given criteria are returned.
Return value
The list of Task
s in this list.
Example
// Outputs the number of incomplete tasks in your Inbox.
const inbox = rtm.getInbox();
console.log('Incomplete tasks in your Inbox: %d',
inbox.getTasks('status:incomplete').length);
getTaskSeries()
Gets all task series in this list.
Return value
The list of TaskSeries
s in this list.
Example
// Outputs all task series in the Inbox.
const taskSeries = rtm.getInbox().getTaskSeries()
.sort((a, b) => a.getName().localeCompare(b.getName()));
taskSeries.forEach((series, i) =>
console.log(`${i + 1}. ${series.getName()}`));
getViewers()
Gets the viewers of the list.
Return value
The list of User
s and Invite
s who can view this list.
isArchived()
Determines whether the list is archived.
Return value
true
if the list is archived, false
otherwise.
Example
// Outputs all archived lists.
rtm.getLists().forEach(list => {
if (list.isArchived()) {
console.log(list.getName());
}
});
isFavorite()
Determines whether the list is marked as a favorite.
Return value
true
if the list is marked as a favorite, false
otherwise.
Example
// Outputs all favorite lists.
rtm.getLists().forEach(list => {
if (list.isFavorite()) {
console.log(list.getName());
}
});
revokeAccess(userOrInvite)
Revokes the access to this list granted to the given user.
Parameters
userOrInvite
The user or invite whose access should be revoked.
Return value
The updated List
.
setFavorite(favorite)
Sets whether the list is marked as a favorite.
Parameters
favorite
true
to mark the list as a favorite,false
otherwise.
Return value
The updated List
.
Example
// Favorites "Personal" list.
const personal = rtm.getLists().find(list => list.getName() === 'Personal');
if (personal != null) {
personal.setFavorite(true);
console.log('Marked "Personal" list as a favorite.');
} else {
console.log('"Personal" list not found.');
}
setName(name)
Sets the list name.
Parameters
name
The new name of the list. Cannot be empty or contain only whitespace.
Return value
The renamed List
.
Example
// Renames "Big Project" list.
const bigProject = rtm.getLists()
.find(list => list.getName() === 'Big Project');
if (bigProject != null) {
bigProject.setName('Project');
console.log('Renamed "Big Project" list');
} else {
console.log('"Big Project" list not found');
}
setOwner(user)
Changes the owner of the list.
Parameters
user
The user who should become the new owner.
Return value
The updated List
.
unarchive()
Unarchives the list.
Return value
The unarchived List
.
Example
// Unarchives "Renovation" list.
const renovationList = rtm.getLists()
.find(list => list.getName() === 'Renovation');
if (renovationList != null) {
renovationList.unarchive();
console.log('Unarchived "Renovation" list.');
} else {
console.log('"Renovation" list not found.');
}