Action Javascript for the UX

Description

Action Javascript adds functionality to your app by defining behaviors using property sheets. The code required to perform the actions is generated for you. These articles cover a wide variety of Action Javascripts available in the UX Component.

 UX Actions

Action
Description
Absolute Layout Container - Create PDF

Create a PDF file from the contents of an Absolute Layout container.

Add Alternative Login to Current User

Add account credentials for an alternative login provider such as Google.

Advanced Export to Excel, Word, HTML, or Ascii using a Report Definition

Export data to Excel, Word, HTML or Ascii using a Report Definition

Ajax Callback

Define a user-defined ajax callback. The callback can be handled by an Xbasic function that is defined in the component, by a separate .a5w page, or by another page (.e.g., .php, .asp, etc.)

Ajax Callback - Cross Domain

Define a user-defined cross-domain ajax callback.

Chart Control Actions

Perform some action on a Chart control (e.g. refresh the chart, export to PDF, etc.).

City, State Lookup from Zip Code

For a given zip code, lookup the city and state on the USPS web site and fill in the city and state in the current record.

Clear a Search a Grid Component that is Embedded into a UX component

For use in conjunction with the 'Search a Grid Component that is Embedded into a UX' action. Clears the search form in the UX and removes the filter from the embedded Grid.

Client-side Data Cache Actions

Perform some action on an item in the Client-side Data Cache (e.g. read the data, refresh the data, etc.).

Delete Alternative Login for Current User

Delete account credentials for an alternative login provider such as Google.

Delete Record

Deletes a record from the Primary Table in a Data Bound UX component.

Dial Telephone Open SMS client

Dial a telephone number or open the SMS client application to send a SMS message.

Display a 'Wait...' message

Display a 'wait...' message when an javascript event happens. The message can include customized text, different display times, as well as custom animations and images.

Editor Actions

Perform some action on an Editor in an Editor set.

Enable or Disable a Button

Set a button's state to either enabled, or disabled.

Fade Out Message

The Fade Out Message action displays a message on the screen for a short period of time. The message fades away after a specified duration.

File Download

Download a file from the server to the user's machine.

File Upload

Upload a file to the server and store a reference to the file in a Grid field, or embed the file in a Drid field.

File Upload - Amazon S3 Storage or Alpha Anywhere Server

Upload one or more files to Amazon S3 or to the Alpha Anywhere server.

File Upload - User Defined

Upload one or more files to the server. A server-side event then gets called to allow you to process the uploaded files.

Filter Records in a List Control

Create a highly customized 'Search Part' to filter the records shown in a List control.

Form View Control Actions

Perform some action on a Form View control.

Geocode an address

Makes an Ajax callback to a web service to geocode an address. Fill in the latitude and longitude fields in the current record with the information.

Geolocation Functions

Get geolocation information from the browser and store information in the current Grid/UX component object (e.g. if you are in a Grid, the data is stored in the {grid.object}.geoLocation object). (Requires an HTML5 browser).

Get Primary Key values for Records in Query

Execute a query and then retrieve the primary key values for the parent table of a Data Bound UX component. (IMPORTANT: This action is intended for an event on a UX component).

Google Map Method (UX Component)

Call a method to perform some action on a Google Map. Actions that you can perform include: Clearing markers, opening or closing an info box, adding a marker to the map, centering the map on an address, setting the map zoom factor.

Hide/Close a window

Close a pop-up Window.

Hide/Close Container Window

Hide (i.e. closes) a Container Window.

Hide/Close PanelOverlay Window

Hides (i.e. closes) a PanelOverlay window. You can optionally animate the window as hidden.

Image Capture for List-Detail View - Camera/Photo Library

This action is used exclusively for image fields in a List Detail View. Capture an image using the camera, or from the photo library. On devices that don't support a camera, select an image from the filesystem.

Image Capture - Camera/Photo Library

Capture an image using the camera, or from the photo library. On devices that don't support a camera, select an image from the filesystem. Action calls a function with the Image URI when the image has been obtained.

Image Delete

Delete an image from an image field.

Image Upload

Upload an image file to the server.

Inline-Javascript

Allows developer to enter javascript code. Unlike most other actions there are no properties to check for the Inline-Javascript action, just the code you want to fire.

Link a Grid that has been embedded into a UX component

Unlike the 'Search a Grid Component that is Embedded into a UX' action which applies a filter to an embedded Grid, this action Links the embedded Grid.

List Control Actions

Perform some action on a List control (e.g. refresh the List, etc) in a UX Component.

Lock/unlock a container, DIV or entire page (by showing an overlay over it)

Lock a container, DIV or entire page by showing an overlay over it so that the user can't click on the controls under the overlay, or unlock the element.

Login with Alternative Login Provider

Login using account credentials from an alternative login provider such as Google.

Lookup and Fill-in Fields

Lookup values in a table and fill-in fields in the current row from fields in the Lookup Table.

Menus

Display a dropdown menu.

Merge data into client-side template

Merge Javascript into a client-side template and set the inner HTML to the result.

Message box

Displays a Javascript alert box on the screen.

New Record

Displays a new record.

Open a AppLauncher component

Open a AppLauncher component in a pop-up window, or in a DIV on the current page.

Open a Calendar component

Open a Calendar component in a pop-up window, or in a DIV on the current page.

Open a Custom component

Open a Custom component in a pop-up window, or in a DIV on the current page.

Open a Google Map component

Open a Google Map component in a pop-up window, or in a DIV on the current page.

Open a Grid component

Opens a grid component in a pop-up window, or in a DIV on the current page. This requires first defining a grid component.

Open a Help Window

Open a window to display a help topic from the Help Table.

Open a ImageGallery component

Open a ImageGallery component in a pop-up window, or in a DIV on the current page.

Open a Page Layout component

Open a Page Layout component in a pop-up window, or in a DIV on the current page.

Open a Pop-up Ajax Window/Overlay

Open a generic, pop-up window (often called an overlay). The window can be modal, or modeless, and can be populated by making an Ajax callback.

Open a Report, Label or Letter layout

Displays a report, label or letter layout as a PDF file using the Acrobat PDF reader. The report is displayed in either a pop-up window or in a DIV on the current page.

Open a UX as an alternate editing view for current record

Open a UX component in a pop-up window, or in a DIV on the current page, to edit the record currently being edited in the Grid or UX component.

Open a UX component

Opens an UX component in a pop-up window, or in a DIV on the current page. (Only new Ajax components can be opened. Old dialogs built in V10 and earilier are not supported.

Open a UX component to Edit Current Record in Grid, or add a new Record

Open an UX component in a pop-up window, or in a DIV on the current page, to edit the current row in a Grid component or to enter a new record. (Only new Ajax Components can be opened. Old Dialogs in V10 and earlier are not supported.)

Open a UX component to Edit Current Record in List Control in a UX, or add a new Record to a List Control in a UX

Open a UX component in a pop-up window, or in a DIV on the current page, to eidt the current page, to edit the current row in a List control in a UX component or to enter a new record into a List. (Applies only to Lists based on SQL or DBF data sources).

Open a Video Player component

Open a Video Player component in a pop-up window, or in a DIV on the current page.

Open an .a5w page, static HTML page, URL, or PDF document, in a pop-up window or a DIV

Open an .a5w page, static HTML page, URL, or PDF document, in a pop-up window or a DIV

Panel Actions

Perform some action on a Panel (e.g. setting focus to the next or previous Panel, or to a particular named panel).

PDF from HTML

Get the HTML inside a container and convert to PDF.

PhoneGap - File Download

Download one or more files and store the files in the filesystem on the mobile device. Uses the PhoneGap FileTransfer feature. (Only applies to UX components running in a PhoneGap shell.)

PhoneGap - File System Actions

Performs actions with the mobile device file system such as creating, reading, deleting file, creating directories, etc.(Only applies to UX components running in a PhoneGap shell.)

PhoneGap - File System Actions (File URI Based)

Performs actions with the mobile device file system such as creating, reading, deleting file, creating directories, deleteing directories, etc. (Only applies to UX components running in a PhoneGap shell.)

PhoneGap - File Upload

Upload one or more files to either the Alpha Anywhere server or to the Amazon S3 using the PhoneGap File Transfer feature. (Only applies to UX components running in a PhoneGap shell.)

PhoneGap - Notifications

Display or initiate a native notification (for example, beep, native alert/prompt/confirmation, vibrate, etc.)

PhoneGap - Send SMS message

Send a SMS message.

PhoneGap - SQLite Actions

Performs actions with the SQLite database on the device. Also allows you to download a SQLite database from the server to the mobile device and create a SQLite database on the server and download it to the device.

Populate Controls in a UX Component with data from Tables

Populate the controls in a UX component with the data from Tables. (IMPORTANT: This action is intended for an event on a UX component).

Populate controls in an UNBOUND UX component with data from a table

Populates controls in a UX component with data from a table. Use this action (rather than the 'Populate Controls in a UX Component with data from Tables' action) if the UX component has not been bound to a database (see the 'Data Binding' pane in the builder).

Refresh/synchronize embedded UX component

Updates the argument values in the child UX component and refreshes the data shown in List controls and other controls that are based on data Series. Also causes the embedded UX component's 'onSynchronizeDialog' (client-side) and 'onSynchronize' (server-side) events to fire.

Run a report that is embedded in a UXcomponent using a custom filter for the report

Create a highly customized 'Search Part' for a Report. Allows you to submit a UX component that contains 'search' fields to compute a filter expression and then run the report using the computed filter expression.

Run Action

The Run Action runs an action that was defined using Javascript.

Search a Grid Component that is Embedded into a UX component

Create a highly customized 'Search Part' for a Grid. Allows you to submit a UX component that contains 'search' fields to compute a filter expression and then filter a Grid component that has been embedded into the UX component.

Send email

This javascript action sends an email.

Show PanelOverlay Window

Show a PanelOverlay window. You can optionally animate the window as it is shown.

Stripe - Process Stripe Payment

Process payment using Stripe. See also the Stripe Genie....

Toggle display of a container or DIV with animation

Adds toggle animation to a DIV or container. When the action is run the dive or container will be shown or hidden using a specified animation such as 'slide' or 'puff'. Different animations can be specified for the show and hide events.

Update, Insert or Delete data. (for use with an UNBOUND component)

Updates, inserts or deletes a record in a table using data submitted from a control on a UX component. The UX component need not have been 'Data Bound' in order to use this action.

Video Player Control Actions

Perform some type of action on a video player control.

ViewBox Control Actions

Perform some action on a ViewBox control (e.g. refresh the ViewBox, etc.)

Web-sockets Server Actions

Performs an action on the web-socket server, such as 'Send a message to the web-sockets server'. The message will be received by all UX and Grid components that are listening for web-socket messages and the 'webSocketOnMessage client-side event in all listening components will fire.

Zip Code Lookup from Address

For a given address, lookup the Zip code on the USPS web site and fill in the current record.

 About the Filter list in Action Javascript

The Define Javascript Action dialog has a filter control to allow you to easily filter the list of actions. This is useful because some developers now have a large number of Javascript Actions defined in their components.

 Try/Catch Blocks

You can wrap individual actions or the entire event in a JavaScript try/catch block. A try/catch block is used to capture unexpected errors in JavaScript code. It is similar to Xbasic's ON ERROR GOTO construct.

To wrap an action in a try/catch block, right-click on the action and select the Wrap action in try/catch block command. This will open an editor where you can define the code to run in the catch block. If an action is configured to use a try/catch block, the menu item will be checked.

An event can include multiple actions. You can wrap the entire event in a try/catch block by checking the Wrap all actions in a try/catch block checkbox at the bottom of the dialog.

See MDN's documentation on 'try...catch' to learn more about JavaScript try/catch blocks.