Memento JavaScript Library: Difference between revisions

mNo edit summary
 
(114 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{Stamp|2017-02-28|4.3.0|1.1.0}
{{Stamp|2021-02-26|4.9.3|1.9.6}}


Memento includes the capability for users to use JavaScript to accomplish complex tasks beyond the capabilities of the normal Memento user interface. Examples include JavaScript fields, Triggers, Actions, and Data Sources. The Memento JavaScript Library may be used to access Memento facilities.
Memento includes the capability for users to use JavaScript to accomplish complex tasks beyond the capabilities of the normal Memento user interface. Examples include JavaScript fields, Triggers, Actions, and Data Sources. The Memento JavaScript Library may be used to access Memento facilities (by all except JavaScript fields).


To keep JavaScript fields both easy and safe for users, they may use only a portion of the library, and the nature of its use is simplified. Any limitations or differences related to JavaScript fields will be identified.
To keep JavaScript fields both easy and safe for users, they may use only a portion of the library, and the nature of its use is simplified. Any limitations or differences related to JavaScript fields will be identified.


== Libraries and Entries ==
== Libraries and Entries ==
=== ''Library'' Global Functions ===
 
=== ''Library'' global functions ===


==== entry() ====
==== entry() ====
: Get the Entry object of the Event. For example, if the script is triggered by an Update Entry event, this function will return the entry being updated.
: Get the Entry object of the Event. For example, if the script is triggered by an Update Entry event, this method will return the entry being updated.


: This Entry object is a clone of the actual Entry object. If the entry is saved, this object will become the actual one, but if cancel() is called, this entry clone, along with any changes the script may have performed, will be discarded.
: This Entry object is a clone of the actual Entry object. If the entry is saved, this object will become the actual one, but if cancel() is called, this entry clone, along with any changes the script may have performed, will be discarded.


: This function is available to all Events and Phases, with the exception of '''Creating an entry''' > '''Opening an Entry Edit card'''; for this action, use the function ''entryDefault()''.
: This global function is available to all Events and Phases, with the exception of '''Creating an entry''' > '''Opening an Entry Edit card'''; for this action, use the global function ''entryDefault()''.


:; Result: [[#Object Entry|'''''Entry''''' object]] — the current entry
:; Result: [[#Object Entry|'''''Entry''''' object]] — the current entry
Line 21: Line 22:


:; Result: [[#Object DefaultEntry|'''''DefaultEntry''''' object]]
:; Result: [[#Object DefaultEntry|'''''DefaultEntry''''' object]]
==== buildDefaultEntry() ====
: The buildDefaultEntry() method is designed to facilitate the customization of default field values during the '''Creating an entry''' or '''Updating an entry''' trigger events, specifically in the '''Opening an Entry Edit card''' phase. When used in the "Creating an entry" trigger event, the buildDefaultEntry() method applies default values for new, copied, or prefilled entries.
:; Result: [[#Object DefaultEntry|'''''DefaultEntry''''' object]]
: '''Properties'''
: The buildDefaultEntry() method allows you to determine the method used by the user to create an entry. Use the following properties for this purpose:
::; buildDefaultEntry().created:  Indicates a new and empty entry.
::; buildDefaultEntry().duplicated: Indicates a duplicate of an existing entry.
::; buildDefaultEntry().prefilled:  Indicates the creation of an entry based on a template.
: '''Usage'''
: The typical usage pattern involves invoking the set() method on the result of buildDefaultEntry() to specify the field name and its corresponding default value.
:: <source lang="JavaScript">
buildDefaultEntry().set("Field name", "Field value");
</source>
: If you want to set default values only when duplicating an entry, you can use the following example:
:: <source lang="JavaScript">
if (buildDefaultEntry().duplicated) {
  buildDefaultEntry().set("Description", "Duplicated Entry")
}
</source>
==== exit() ====
: Stops script execution


==== lib() ====
==== lib() ====
Line 37: Line 66:


=== Object ''Library'' ===
=== Object ''Library'' ===
This object provides access to library entries. You can work with the current library &mdash; the ''lib()'' &mdash; or any other library in the database &mdash; ''libByName()''. This function provides the ability to update existing entries and create new ones.
This object provides access to library entries. You can work with the current library &mdash; the ''lib()'' &mdash; or any other library in the database &mdash; ''libByName()''. This global function provides the ability to update existing entries and create new ones.
 
==== ''Library'' methods ====
 
===== create(values) =====
: Create a new entry in the library
: '''Argument'''
::; values: [https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object '''''Object'''''] containing the field values as its properties
:; Result: [[#Object entry|'''''Entry''''' object]] &mdash; the new entry to create in the library


==== ''Library'' Methods ====
===== entries() =====
===== entries() =====
: Get all the entries of the library
: Get all the entries of the library
:; Result: Array object containing entries, sorted by the time of their creation, from newest to oldest
:; Result: Array object containing entries (Entry objects), sorted by the time of their creation, from newest to oldest
 
===== fields() =====
: Get some of the fieldnames of the library
:; Result: Array object containing the strings, in definition order. Only the names of the fields defined in the MAIN page and not appearing within a Subheader will be returned, as of Memento release 4.13.


===== find(query) =====
===== find(query) =====
: Search field values within entries in the library matching the given query. This search is similar to searching via Memento's user interface.
: Search field values within entries in the library matching the given query. This search is similar to searching via Memento's user interface.
:; Argument: '''query''' &mdash; the search string
: '''Argument'''
::; query: the search string
:; Result: Array object containing matching entries. Entries are sorted by the time of their creation, from newest to oldest.
:; Result: Array object containing matching entries. Entries are sorted by the time of their creation, from newest to oldest.
===== findById(id) =====
: Search all entries by entry ID.
: '''Argument'''
::; id: the ID string uniquely identifying the entry.
:; Result: [[#Object Entry|'''''Entry''''' object]], if found. Otherwise, ''null''.


===== findByKey(name) =====
===== findByKey(name) =====
: Search all entries by the Entry Name. The library must be set for unique Entry Names.
: Search all entries by the entry name. The library must be set for unique entry names.
:; Argument: '''name''' &mdash; the Entry Name field value
: '''Argument'''
:; Result: [[#Object Entry|'''''Entry''''' object]], if found. Otherwise, ''null''.
::; name: the Entry name field value(s)
:; Result: an [[#Object Entry|'''''Entry''''' object]], if found. Otherwise, ''null''.


===== create(values) =====
===== linksTo(entry) =====
: Create a new entry in the library
Get entries in the library that contain a link to the specified entry.
:; Argument: '''values''' &mdash; [[https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object '''''Object'''''] containing the field values
: '''Arguments'''
:; Result: [[#Object entry|'''''Entry''''' object]] &mdash; the new entry in the library
::; entry: An entry to search for links to it.
:; Result: Array object containing entries.


===== show() =====
===== show() =====
: Display the library
: Display the library


==== ''Library'' Properties ====
==== ''Library'' properties ====
: '''title''' &mdash; The name of the library
:; name: The name of the library
:; title: The name of the library


<br/>
<br/>
Line 70: Line 120:
This object holds an entry of the current library, allowing the setting of field values
This object holds an entry of the current library, allowing the setting of field values


==== ''Entry'' Methods ====
==== ''Entry'' methods ====
===== set(name, value) =====
: Set the value of the named field. Calling this method results in immediate writing of the value to the library.
 
:'''Note:''' In the case where the field to be set is a Link To Entry field, the second argument should be the entry name of the entry to link to. If there are, in that library, multiple fields set as Entry Name, the entry name for the set() method is formed by separating the value of those fields by a comma (,) &mdash; not a comma and a space, but only a comma.
 
:; Arguments
:: '''name''' &mdash; name of the field
:: '''value''' &mdash; the value of the field


===== field(name) =====
===== field(name) =====
: Get the value of the named field
: Get the value of the named field
:; Argument: '''name''' &mdash; name of the field
: '''Argument'''
::; name: name of the field
:; Result: The value of the field. The type of the result depends on the type of the field.
:; Result: The value of the field. The type of the result depends on the type of the field.


::{{FieldTypeReturnValues}}
::{{FieldTypeReturnValues}}
===== link(name, entry) =====
: Add a link &mdash; to a Link to Entry field in the current library &mdash; to an entry in the related library.
: '''Arguments'''
::; name: Name of the Link to Entry field to which to add the link
::; entry: Entry in the field's related library to which to link
===== images(name) =====
: The images(name) method is designed to facilitate easy retrieval and manipulation of images associated with a specified field in the entry.
: '''Arguments'''
::; name: Name of the Image field
: '''Return Value'''
: An array of objects, each representing an image associated with the specified field.
::; caption: Get or set the caption for the image.
::; uri: Retrieve the URI (link) of the image.
===== recalc() =====
: Recalculate values of entry fields.
===== trash() =====
: Moves an entry into the trash.
===== untrash() =====
: Moves an entry out of the trash.
===== set(name, value) =====
: Set the value of the named field. Calling this method results in immediate writing of the value to the library.
:'''Note:''' In the case where the field to be set is a Link To Entry field, the second argument should be the entry name of the entry to link to. If there are, in that library, multiple fields set as the entry name, the entry name for the set() method is formed by separating the value of those fields by a comma (,) &mdash; not a comma and a space, but only a comma.
: '''Arguments'''
::; name: name of the field
::; value: the value of the field
:::* For Multiple-choice List and Checkboxes fields, an array of strings supplies the values.
:::* For Link to Entry fields, an array of of strings &mdash; each of which may be a comma-separated list of field names &mdash; supplies the entry names of entries to which to link.
:::* For Link to File fields, an array of path names identifies the files to which to link.


===== show() =====
===== show() =====
: Display the entry
: Display the entry


==== ''Entry'' Properties ====
===== unlink(name, entry) =====
: '''name''' &mdash; entry name
: Remove a link &mdash; from a Link to Entry field in the current library &mdash; to an entry in the related library.
: '''title''' &mdash; entry name
: '''Arguments'''
: '''description''' &mdash; entry description
::; name: Name of the Link to Entry field from which to remove the link
: '''favorites''' &mdash; true, if the entry is in Favorites
::; entry: Entry in the field's related library identifying the link to be removed
: '''deleted''' &mdash; true, if the record is deleted (it is in the Recycle Bin)
 
==== ''Entry'' properties ====
:; author: the id of the user who created the entry
:; creationTime: date & time the entry was created
:; deleted: true, if the entry is deleted (it is in the Recycle Bin)
:; description: entry description
:; favorites: true, if the entry is in Favorites
:; id: entry identifier
:; lastModifiedTime: date & time the entry was last modified
:; name: entry name
:; title: entry name
<br/>
<br/>


Line 101: Line 191:
Template with default values for a new entry. This feature is available specifically and only for the Event '''Creating an entry''' & Phase '''Opening an Entry Edit card'''.
Template with default values for a new entry. This feature is available specifically and only for the Event '''Creating an entry''' & Phase '''Opening an Entry Edit card'''.


==== ''DefaultEntry'' Methods ====
==== ''DefaultEntry'' methods ====
 
===== set(name, value) =====
===== set(name, value) =====
: Set the value of the field
: Set the value of the field


:; Arguments
: '''Arguments'''
:: '''name''' &mdash; the name of the field
::; name: the name of the field
:: '''value''' &mdash; the value of the field
::; value: the value of the field
<br/>
<br/>
=== Library & Entry objects examples ===
=== Library & Entry objects examples ===
'''[[Trigger Examples#Library Examples]]'''
See '''[[Trigger Examples#Libraries examples]]'''.
<br/>
-----
<br/>


== Working with files ==
== Working with files ==
With scripts, you can read or write files located in the device's internal memory or on the SD card. All file operations are performed by the ''File'' object, which is obtained via a global function called ''file()''.
With scripts, you can read or write files located in the device's internal memory or on the SD card. All file operations are performed by the ''File'' object, which is obtained via a global function called ''file()''.


To work with the files, the library should have read/write file access.
To work with the files, the library should have read/write file access. Also, in the Android app, select a folder that your script will have access to. You can configure this folder in the script permission dialog.
 
=== ''File'' global functions ===


=== ''File'' Global Functions ===
==== file(name) ====
==== file(name) ====
Open a file for read or write operations. If the file with the specified name does not exist yet, it will be created.
Open a file for read or write operations. If the file with the specified name does not exist yet, it will be created.


:; Argument
: '''Argument'''
:: '''name''' &mdash; The name and the full path to the file. For example, if the file is located on the SD card, the path should be something like /sdcard/example.txt.
::; name: The name of the file in the chosen folder is accessible to scripts. In the Desktop app, you must specify the full file path.


:; Result
:; Result
Line 131: Line 227:
This object is returned by the global function ''file()'' and provides access to the requested file. After reading or writing, the file should be closed using the method ''close()''.
This object is returned by the global function ''file()'' and provides access to the requested file. After reading or writing, the file should be closed using the method ''close()''.


==== ''File'' Methods ====
==== ''File'' methods ====
; readAll()
 
: Reads all lines of the file, and then closes the file
:; close(): Close the file. It can subsequently be reopened.
:; Returns
 
:: Array containing the lines of the file
:; getLineNumber(): Get the current line number
::; Returns: The line number, or position, in the file
 
:; readAll(): Reads all lines of the file, and then closes the file
::; Returns: Array containing the lines of the file


; readLine()
:; readChar(): Reads the next character from the file stream
: Reads the next line from the file stream
::; Returns: The character
:; Returns: The line


; readLines()
:; readLine(): Reads the next line from the file stream
: Reads the remaining lines from the file stream
::; Returns: The line
:; Returns: Array containing the remaining lines of the file


; readChar()
:; readLines(): Reads the remaining lines from the file stream
: Reads the next character from the file stream
::; Returns: Array containing the remaining lines of the file
:; Returns: The character


; write(text)
:; write(text): Write string(s). Take a variable number of arguments, converts each argument to a string, and writes that string to the file stream.
: Write string(s). Take a variable number of arguments, converts each argument to a string, and writes that string to the file stream.


; writeLine(text)
:; writeLine(text): Write strings and a newline to the file stream
: Write strings and a newline to the file stream


; close()
:; appendMode(): Switch the file to append mode, allowing data to be added to the end of the file without overwriting existing content.
: Close the file. It can subsequently be reopened.


==== ''File'' Properties ====
==== ''File'' properties ====
:; exists: true &mdash; if and only if the file exists; false otherwise
:; exists: true &mdash; if and only if the file exists; false otherwise
:; length: The length, in bytes, of the file, or 0L if the file does not exist.  
:; length: The length, in bytes, of the file, or 0L if the file does not exist.  
:; getLineNumber: Get the current line number
::; Returns: The line number, or position, in the file
<br/>
<br/>


=== Files Examples ===
=== Files examples ===
See '''[[Trigger Examples#Files Examples]]'''.
See '''[[Trigger Examples#Files examples]]'''.
<br/>
<br/>
-----
-----
Line 183: Line 275:
Interface for processing HTTP requests
Interface for processing HTTP requests


==== ''Http'' Methods ====
==== ''Http'' methods ====
 
===== http() =====
: Get the Http object
<br/>
 
===== get(url) =====
===== get(url) =====
: Execute HTTP get request
: Execute HTTP GET request
:; Argument: '''url''' &mdash; HTTP address, starting with http or https
: '''Argument'''
:; Result: '''HttpResult''' &mdash; Object containing the result of the execution of the HTTP request
::; url: HTTP address, starting with http:// or https://
: '''Result'''
::; HttpResult: Object containing the result of the execution of the HTTP request
<br/>
 
===== post(url, body) =====
: Execute HTTP POST request
: '''Arguments'''
::; url: HTTP address, starting with http:// or https://
::; body: The text of the HTTP POST request
: '''Result'''
::; HttpResult: Object containing the result of the execution of the HTTP request
: '''Example'''
:: <source lang="JavaScript">
var result = http().post("http://httpbin.org/post", "the body of the request message");
</source>
<br/>
<br/>
===== headers(info) =====
: Set up header
'''Argument'''
::; info: Header text
: '''Result'''
::; HttpResult: Object containing the result of the execution of the HTTP request
: '''Example'''
<source lang="JavaScript">
var http = http();
http.headers({"User-Agent": "My Super App"});  // Set up the header
var result = http.get("http://httpbin.org/get");  // Do a GET
var headerValue = result.header("etag");  // Get response header
</source>


=== Object ''HttpResult'' ===
=== Object ''HttpResult'' ===
Result of the execution of the HTTP request
Result of the execution of the HTTP request


==== ''HttpResult'' Properties ====
==== Properties ====
: '''code''' &mdash; HTTP code of the response, if the request is successful (usually 200).
:; body: The response in text form
: '''body''' &mdash; The response in text form
:; code: HTTP code of the response, if the request is successful (usually 200).
<br/>
<br/>


=== Http Examples ===
==== ''Method'' ====
See '''[[Trigger Examples#Http Examples]]'''.
 
===== header(tag) =====
'''Argument'''
::; tag: ???
 
=== Http examples ===
See '''[[Trigger Examples#Http examples]]'''.
<br/>
<br/>
-----
-----
<br/>
<br/>


== Interaction with the System ==
== Performing email functions ==
=== ''System'' Global Functions ===
 
==== message(text) ====
=== ''Email'' global functions ===
: Shows the user a brief notification
 
:; Argument: '''text''' &mdash; Text of the notification
==== email() ====
: Returns the system Email object. Methods of the Email object may be used to send email messages, among other things. See the [[#Object Email|'''''Email''''' object]].
 
=== Object ''Email'' ===
This object provides methods related to email.
 
==== ''Email'' global functions ====
:; send(): Send an email message based on a provided Smtp configuration object and other arguments.
:: '''Arguments'''
:::; cfg: The EmailConfig object to use for this email message
:::; to: The email address to which to send the email message
:::; subject: Text for the "Subject:" line
:::; message: Body text of the email message
 
=== Object ''EmailConfig'' ===
 
==== ''EmailConfig'' properties ====
 
:; host: The SMTP server from which to base email requests
 
:; port: The UDP port to use for email communications
 
:; user: The user within the host in whose name to make email requests
 
:; pass: The password for the user
 
:; from: The email address for the email "From:" line
 
=== Email example ===
Send an email message in the background
<source lang="JavaScript">
// Send email example
// You must use the Object to specify SMTP configuration:
//  SMTP server host, port, username, password, email address
 
var cfg = {"host" : "smtp.example.com" , "port":25,
"user":"username" , "pass":"password" , "from":"username@example.com"};
email().send(cfg , "to@email.com" , "Subject" , "Text");
</source>
 
== Interaction with the system ==
 
=== ''System'' global functions ===


==== cancel() ====
==== cancel() ====
: Stop the system operation that caused the event. Many triggers can be a result of an entry manipulation (create, update, delete, etc). The ''cancel()'' function can be used during the phases that precede the system operation. For example, this function can be used during data validation before the entry is saved.
: Stop the system operation that caused the event. Many triggers can be a result of an entry manipulation (create, update, delete, etc). The ''cancel()'' function can be used during the phases that precede the system operation. For example, this function can be used during data validation before the entry is saved.
==== system() ====
: Obtain information about the system
:; Result: [[#Object System|'''''System''''' object]]
==== log(text) ====
: Write a line to the log file
:; Argument: '''text''' &mdash; text to be written to the log


==== guid() ====
==== guid() ====
Line 227: Line 393:
==== intent(action) ====
==== intent(action) ====
: Create an information exchange object &mdash; Intent. This function can send a request for action to another application.
: Create an information exchange object &mdash; Intent. This function can send a request for action to another application.
: This function is available only on Android.
: '''This function is available only on Android.'''
:; Argument: '''action''' &mdash; Line that defines standard action (eg, view, pick)
: '''Argument'''
::; action: Line that defines standard action (eg, view, pick)
:; Result: [[#Object Intent|'''''Intent''''' object]] &mdash; Information exchange object
:; Result: [[#Object Intent|'''''Intent''''' object]] &mdash; Information exchange object
: After the object is received, the data will be added to it, and then sent via ''send()''.
: After the object is received, the data will be added to it, and then sent via ''send()''.
: Android has many built-in actions. A list of these actions can be found [https://developer.android.com/reference/android/content/Intent.html '''here'''].
: Android has many built-in actions. A list of these actions can be found [https://developer.android.com/reference/android/content/Intent.html '''here'''].
==== log(text) ====
: Write a line to the log file
: '''Argument'''
::; text: text to be written to the log
==== message(text) ====
: Shows the user a brief notification
: '''Argument'''
::; text: Text of the notification
==== dialog() ====
: Create a builder for constructing and displaying a dialog
:; Result: [[#Object Dialog|'''''Dialog''''' object]]
==== system() ====
: Obtain information about the system
:; Result: [[#Object System|'''''System''''' object]]
<br/>
<br/>


Line 237: Line 423:
This object contains information about the system.
This object contains information about the system.


==== ''System'' Properties ====
==== ''System'' global functions ====
: '''os''' &mdash; Name of the operating system executing the script
:; exit(): End script execution
 
==== ''System'' properties ====
:; os: Name of the operating system executing the script
<br/>
 
=== Object ''Dialog'' ===
The Dialog object provides a set of methods to configure and customize the appearance and behavior of the dialog.
 
'''Usage'''
 
To use the Dialog object, instantiate it using dialog() method and then chain the available methods to configure the dialog as needed. Finally, call the show() method to display the constructed dialog to the user.
<source lang="javascript">
const myDialog = dialog()
myDialog.title("Hello")
        .text("Welcome to our application.")
        .positiveButton("OK", () => { /* Handle positive button click */ })
        .show();
</source>
'''Methods'''
:; title(string): Sets the title of the dialog. Accepts a string parameter that represents the title to be displayed.
:; text(string): Sets the main text content of the dialog. Accepts a string parameter that represents the primary message or content of the dialog.
:; view(ui object): Sets a custom view for the dialog. Accepts a [[Memento_JavaScript_UI|UI object]] that represents the custom view to be displayed within the dialog.
:; positiveButton(text, function()): Configures the positive button of the dialog. Accepts two parameters: the text to be displayed on the button and the function to be executed when the button is clicked.
:; negativeButton(text, function()): Configures the negative button of the dialog. Accepts two parameters: the text to be displayed on the button and the function to be executed when the button is clicked.
:; neutralButton(text, function()): Configures the neutral button of the dialog. Accepts two parameters: the text to be displayed on the button and the function to be executed when the button is clicked.
:; autoDismiss(bool): Sets whether the dialog should automatically dismiss when a button is clicked. Accepts a boolean parameter. If autoDismiss is set to false, the dialog will only close when a button function returns true.
:; show(): Displays the configured dialog to the user.
<br/>
<br/>


Line 244: Line 457:
Information exchange object. This object is created by using the global function ''intent()''.
Information exchange object. This object is created by using the global function ''intent()''.


==== ''Intent'' Methods ====
==== ''Intent'' methods ====
 
===== data(uri) =====
===== data(uri) =====
: Define URI to reference the data
: Define URI to reference the data
:; Argument
: '''Argument'''
:: uri &mdash; URI referencing data to which the action will be applied. It can be contact ID, path to the file, phone number, etc.
::; uri: URI referencing data to which the action will be applied. It can be contact ID, path to the file, phone number, etc.
 
===== mimeType(mime) =====
: Define MIME type of the data
:; Argument
:: mime &mdash; MIME type of the data on which the operation will be performed


===== extra(key, value) =====
===== extra(key, value) =====
: Define additional data as key-value pairs, as necessary for execution of the required action. Similar to how URI data can be required for certain actions, other actions may require extra data in this format.
: Define additional data as key-value pairs, as necessary for execution of the required action. Similar to how URI data can be required for certain actions, other actions may require extra data in this format.
:; Arguments
: '''Arguments'''
:: key and value
::; key: key for additional data item
::; value: value of additional data item


===== extraLong(key, value) =====
===== extraLong(key, value) =====
: Define additional data as key-value pairs, where data type needs to be Long
: Define additional data as key-value pairs, where data type needs to be Long
:; Arguments
: '''Arguments'''
:: key and value
::; key: key for additional data item
::; value: value of additional data item
 
===== mimeType(mime) =====
: Define MIME type of the data
: '''Argument'''
::; mime: MIME type of the data on which the operation will be performed


===== send() =====
===== send() =====
Line 269: Line 485:
<br/>
<br/>


=== System Examples ===
=== System examples ===
See '''[[Trigger Examples#System Examples]]'''.
See '''[[Trigger Examples#System examples]]'''.
<br/>
<br/>
-----
-----
Line 283: Line 499:
If the Contact field contains multiple contacts, use ''hasNext'' and ''next'' to retrieve them.
If the Contact field contains multiple contacts, use ''hasNext'' and ''next'' to retrieve them.


==== JSContact Methods ====
==== JSContact methods ====


:; show(): Opens the Contacts app for this contact
:; call(): If the device is a phone, calls the primary phone number of this contact


:; call(): If the device is a phone, calls the primary phone number of this contact
:; sendEmail(subject, message): Sends an email message to the primary email address of this contact, with subject '''''subject''''' and message '''''message''''' (text string)


:; sendSMS(message): If the device is a phone, sends the provided '''''message''''' (text string) as an SMS message to the primary phone number of this contact
:; sendSMS(message): If the device is a phone, sends the provided '''''message''''' (text string) as an SMS message to the primary phone number of this contact


:; sendEmail(subject, message): Sends an email message to the primary email address of this contact, with subject '''''subject''''' and message '''''message''''' (text string)
:; show(): Opens the Contacts app for this contact


==== JSContact Properties ====
==== JSContact properties ====
 
:; email: The primary email address of this contact


:; fullName: The full name of this contact
:; fullName: The full name of this contact


:; phone: The primary phone number of this contact
:; hasNext: Returns TRUE if there is a next JSContact object, otherwise FALSE


:; email: The primary email address of this contact
:; next: Returns the next JSContact object, if there is one.


:;hasNext: Returns TRUE if there is a next JSContact object, otherwise FALSE
:; phone: The primary phone number of this contact


:;next: Returns the next JSContact object, if there is one.
<br/>


<br/>
=== Object ''JSGeolocation'' ===
=== Object ''JSGeolocation'' ===


Line 314: Line 531:
If the Location field contains multiple locations, use ''hasNext'' and ''next'' to retrieve them.
If the Location field contains multiple locations, use ''hasNext'' and ''next'' to retrieve them.


==== JSGeolocation Properties ====
==== JSGeolocation properties ====
 
:; address: Address for this Location
 
:; hasNext: Returns TRUE if there is a next JSGeolocation object, otherwise FALSE


:; lat: Latitude, as a Real
:; lat: Latitude, as a Real


:; lng: Longitude, as a Real
:; lng: Longitude, as a Real
:; address: Address for this Location
:; hasNext: Returns TRUE if there is a next JSGeolocation object, otherwise FALSE


:; next: Returns the next JSGeolocation object, if there is one.  
:; next: Returns the next JSGeolocation object, if there is one.  
Line 328: Line 545:
<br/>
<br/>


=== Built-in Objects Examples ===
=== Built-in Objects examples ===
See '''[[Trigger Examples#Built-in Objects Examples]]'''.
See '''[[Tips:Trigger Examples#Examples of built-in object use|Examples of built-in object use]]'''.
<br/>
<br/>
-----
-----
Line 335: Line 552:


== See also ==
== See also ==
; [[Script Actions]]: Memento Actions
; [[Actions]]: Memento Actions
; [[Script Data Sources]]: Memento Data Sources
; [[Data Sources]]: Memento Data Sources
; [[Triggers]]: Memento Triggers
; [[Triggers]]: Memento Triggers
; [[Trigger Examples]]: Examples of Memento Triggers
; [[Trigger Examples]]: Examples of Memento Triggers
; [[Tips:Using JavaScript in Memento]]: Tips for using JavaScript in Memento


=== JavaScript links ===
=== JavaScript links ===
Line 345: Line 563:
-----
-----
<br/>
<br/>
[[Category:en]] [[Category:Spec]] [[Category:Sc]]