Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 365: | Line 365: | ||
</source> | </source> | ||
== | == Interaction with the System == | ||
=== | === Global Methods === | ||
====message(text)==== | ==== message(text) ==== | ||
: | :Shows the user a brief notifiction | ||
: | :Argument: text — Text of the notification | ||
====cancel()==== | ==== cancel() ==== | ||
: | : Stop the system operation that caused the event. Many triggers can be a result of 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()==== | ==== system() ==== | ||
: | : Obtain information about the system | ||
: | :Result: System object | ||
====log(text)==== | ==== log(text) ==== | ||
: | : Write a line to the log file | ||
: | : Argument: Text - text to be written to the log | ||
====guid()==== | ==== guid() ==== | ||
: | : Generates random text identifier | ||
: | : Result: Random string identifier | ||
====intent(action)==== | ==== intent(action) ==== | ||
: | : Create an information exchange object — Intent. This function can send a request for action to another application. | ||
: | : This function is available only on Android. | ||
: | : Argument: action — Line that defines standard action (eg, view, pick) | ||
: | : Result: Intent — Information exchange object | ||
: | : 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 at [https://developer.android.com/reference/android/content/Intent.html here]. | ||
=== Object System === | === Object System === | ||
This object contains information about the system. | |||
==== | |||
;os : | ==== Properties ==== | ||
;os : Name of the operating system executing the script | |||
=== Object Intent === | === Object Intent === | ||
Information exchange object. This object is created by using the global method intent(). | |||
==== Methods ==== | ==== Methods ==== | ||
=====data(uri)===== | ===== data(uri) ===== | ||
: | : Define URI to reference the data | ||
: | : Argument: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)===== | |||
: | ===== mimeType(mime) ===== | ||
: | : Define MIME type of the data | ||
=====extra(key, value)===== | : Argument:mime — MIME type of the data on which the operation will be performed | ||
: | |||
: | ===== extra(key, value) ===== | ||
=====extraLong(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. | ||
: | : Arguments: key and value | ||
===== extraLong(key, value) ===== | |||
: Define additional data as key-value pairs, where data type needs to be Long | |||
=====send()===== | =====send()===== | ||
: | : Send a message | ||
=== Examples === | |||
==== Script to open a screen for dialing a number ==== | |||
Suppose a library contains a field called Phone containing a phone number. | |||
<source lang="javascript" line> | <source lang="javascript" line> | ||
i = intent("android.intent.action.DIAL") | i = intent("android.intent.action.DIAL") // Create information exchange object Intent with the action of DIAL | ||
i.data("tel:"+entry().field("Phone")) | i.data("tel:"+entry().field("Phone")) // The data will be the phone number obtained from the field Phone | ||
i.send() | i.send() // Send the message | ||
</source> | </source> | ||
==== | ==== Script to open app to send SMS message ==== | ||
The phone number will be obtained from the field Phone and the text of the message will be obtained from the fields ContactName and Notes. | |||
<source lang="javascript" line> | <source lang="javascript" line> | ||
msg = "Dear, " + entry().field("ContactName") + "\n" + entry().field("Notes") | msg = "Dear, " + entry().field("ContactName") + "\n" + entry().field("Notes") // Form the message from ContactName & Notes | ||
i = intent("android.intent.action.SENDTO") | i = intent("android.intent.action.SENDTO") // Create intent object to open the app for sending | ||
i.data("smsto:"+entry().field("Phone")) | i.data("smsto:"+entry().field("Phone")) // Provide the phone number in format smsto:number | ||
i.extra("sms_body" , msg) | i.extra("sms_body" , msg) // Insert the text of the message to sms_body | ||
i.send() | i.send() // Send the message | ||
</source> | </source> | ||
# Составляем сообщение из значений полей ContactName и Notes | # Составляем сообщение из значений полей ContactName и Notes | ||
# Создаем объект обмена сообщениями Intent и указываем действие которое откроет приложение для отправки сообщений- android.intent.action.SENDTO. | # Создаем объект обмена сообщениями Intent и указываем действие которое откроет приложение для отправки сообщений- android.intent.action.SENDTO. |