MilkScript

Automate tasks with MilkScript.

menu

TaskSeries

Represents a series of tasks (a recurring task). A task series is a grouping of tasks generated by a recurrence pattern (more specifically, a recurrence pattern of type every – an after type recurrence generates a new task series for every occurrence).

Task series' share common properties such as:

  • Name
  • Recurrence pattern
  • Tags
  • Location
  • Notes
  • Priority
  • URL


getId()

Gets the ID of the task series.

Return value

string


getLocation()

Gets the location of the task series.

Return value

The Location of the task series, or null if the task series has no location.

Example

// Outputs every task series in the Inbox that has a location.
const taskSeries = rtm.getInbox().getTaskSeries()
  .sort((a, b) => a.getName().localeCompare(b.getName()));

taskSeries.forEach(series => {
  const location = series.getLocation();

  if (location != null) {
    console.log(`${series.getName()} - ${location.getName()}`);
  }
});

getName()

Gets the name of the task series.

Return value

The name of the TaskSeries.

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()}`));

getNotes()

Gets the notes of the task series.

Return value

The list of Notes.

Example

// Outputs the total number of notes in the Inbox.
const taskSeries = rtm.getInbox().getTaskSeries();

const total = taskSeries.reduce((result, series) => result + series.getNotes().length, 0);

console.log("Total notes in the Inbox: %d", total);

getPriority()

Gets the priority of the task series.

Return value

The Priority of the task series.

Example

// Outputs the priority of 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()} - ${series.getPriority()}`));

getTags()

Gets the tags of the task series.

Return value

The list of Tags.

Example

// Outputs tagged task series in the Inbox.
const taskSeries = rtm.getInbox().getTaskSeries()
  .sort((a, b) => a.getName().localeCompare(b.getName()));

taskSeries.forEach(series => {
  const tags = series.getTags().map(tag => tag.getName()).join(', ');
  if (tags) {
    console.log(`${series.getName()} - [${tags}]`);
  }
});

getTasks()

Gets all tasks in this series.

Return value

The list of Tasks in this series. There is always at least one task in the series.

Example

// Outputs a task series in the Inbox that has the highest number of tasks.
const taskSeries = rtm.getInbox().getTaskSeries();

const largest = taskSeries.reduce(
    (result, series) => result == null                      ? series :
        result.getTasks().length < series.getTasks().length ? series :
                                                              result,
    null);

const output = largest == null ?
    'You have no tasks in the Inbox.' :
    largest.getTasks().length === 1 ?
    `"${largest.getName()}" has never repeated.` :
    `"${largest.getName()}" has repeated ${largest.getTasks().length - 1} times.`;

console.log(output);

getUrl()

Gets the URL of the task series.

Return value

The URL, or null if the task series has no URL set.

Example

// Outputs task series in the Inbox that have a URL set.
const taskSeries = rtm.getInbox().getTaskSeries()
  .sort((a, b) => a.getName().localeCompare(b.getName()));

taskSeries.forEach(series => {
  const url = series.getUrl();
  if (url != null) {
    console.log(`${series.getName()} - ${url}`);
  }
});

isRecurring()

Determines whether this task series has a recurrence pattern.

Return value

true if the task series has a recurrence pattern, false otherwise.