Options
All
  • Public
  • Public/Protected
  • All
Menu

Drafts Script Reference

Index

Type aliases

capitalizationTypes

capitalizationTypes: "none" | "sentences" | "words"

draftFolderTab

draftFolderTab: "inbox" | "flagged" | "archive" | "trash" | "all"

dropboxMode

dropboxMode: "add" | "overwrite"

googleTask

googleTask: object

Represents Task for use with GoogleTask object. Property details available in Task API reference

googleTaskList

googleTaskList: object

Represents Task List for use with GoogleTask object. Property details available in Task API reference

keyboardTypes

keyboardTypes: "default" | "numbersAndPunctuation" | "numberPad" | "phonePad" | "namePhonePad" | "emailAddress" | "decimalPad" | "webSearch" | "URL"

mailStatus

mailStatus: "created" | "sent" | "savedAsDraft" | "mailUnavailable" | "userCancelled" | "invalid" | "serviceError" | "unknownError"

The Mail object can be used to create and send mail messages, similar to those created by a "Mail" action step.

Example

var mail = Mail.create();
mail.toRecipients = ["joe@sample.com"];
mail.subject = "My test message";
mail.body = "Body text";

var success = mail.send();
if (!success) {
  console.log(mail.status);
  context.fail();
}

microsoftToDoLinkedResource

microsoftToDoLinkedResource: object

Represents Linked Resource for use with MicrosoftToDo object. Property details available in To Do API reference

microsoftToDoTask

microsoftToDoTask: object

Represents Task for use with MicrosoftToDo object. Property details available in To Do API reference

microsoftToDoTaskList

microsoftToDoTaskList: object

Represents Task List for use with MicrosoftToDo object. Property details available in To Do API reference

navigationMarker

navigationMarker: { label: string; length: number; level: number; location: number; prefix: string }

An object describing a navigation location, as defined by the syntax definition in use in the editor

Type declaration

  • label: string

    Label text for the marker.

  • length: number

    The number of characters in the range.

  • level: number

    Indentation level of the marker.

  • location: number

    The start location of the range of text representing the marker.

  • prefix: string

    Prefix text for the marker. Example: H1, H2 in Markdown

queryDateField

queryDateField: "created" | "modified" | "accessed"

queryDateType

queryDateType: "relative" | "absolute"

selectionRange

selectionRange: Array<number>

An array of numbers containing the location (index in string), and length (number of characters) of a text selection.

sortBy

sortBy: "created" | "modified" | "accessed" | "name"

syntaxType

syntaxType: "builtIn" | "custom" | "file"

themeType

themeType: "builtIn" | "custom" | "file"

Variables

Const action

action: Action

The current running action. This can be used in script to branch based on action name.

Const app

app: App

Reference to current app object.

Const context

context: Context

Const device

device: Device

Current device.

Const draft

draft: Draft

When an action is run, a single draft is always in context and accessible via the draft const. This usually points to the draft loaded in the editor at the time the action was run if running actions from the action list or action bar.

Const editor

editor: Editor

The active editor

Date Functions

adjustDate

  • adjustDate(date: Date, adjustmentExpression: string): Date
  • Move a date forward or backward in time based on the simple adjustment expression.

    Parameters

    • date: Date

      Valid date object

    • adjustmentExpression: string

      An series of date adjustment values in the format (+|-)(integer) (unit), such as "+1 year", "-1 month -12 hours". Supported units: year, month, day, hour, minute, second. Units may be in singular or plural form.

    Returns Date

strftime

  • strftime(date: Date, format: string): string

Other Functions

alert

  • alert(message: string): void
  • Shows a simple alert dialog containing the message.

    Parameters

    • message: string

    Returns void

require

  • require(path: string): void
  • Include the contents of a script loaded from iCloud Drive. The contents of the script will be evaluated as if they were inline with the current script. Useful for loading reusable libraries and utility scripts.

    Parameters

    • path: string

      relative path to javascript file in the iCloud Drive /Drafts/Library/Scripts folder. For example, to load the script in the file test.js in the iCloud Drive/Drafts/Library/Scripts/Utilities/ folder, use the path parameter Utilities/test.js.

    Returns void

Generated using TypeDoc