Advanced Trigger Setup

Description

Examples of how to set up a client side trigger.

Options

Different types of database events cause the client trigger to be fired.

These include the following events: accept, update.

How To Create a Client Side Trigger

Example 1: Simple Javascript Alert

  1. Open the Client Trigger view under: Admin Views -> Project Essentials -> Client Triggers

  2. Add the following new entry:

    Event

    accept|my_project/my_sType

    Callback

    my_script_folder/my_client_side_script

  3. Open the Script Editor (keyboard short-cut is "9") and create the following entry:

    Script Path

    my_script_folder/my_client_side_script

    script type

    javascript

    code

    log.critical(input)

  4. Go to the view of the sType my_project/my_sType.

  5. Refresh the tab if the view is stale.

  6. Modify an entry and click off the field. The changed cell should turn green.

    Notice in the web browser Javascript console output, the contents of the input object is displayed. You can access useful information in there like search key by specifying "input.search_key".

Example 2: Refresh the row after it is saved

  1. Open the Client Trigger view under: Admin Views -> Project Essentials -> Client Triggers

  2. Add the following new entry:

    Event

    update|my_project/my_sType2

    Callback

    my_script_folder/my_client_side_script2

  3. Open the Script Editor (keyboard short-cut is "9") and create the following entry:

    Script Path

    my_script_folder/my_client_side_script2

    script type

    javascript

    code

    (see code below)

  4. Go to the view of the sType my_project/my_sType2.

  5. Refresh the tab if the view is stale.

  6. Modify an entry's description field. Try typing in "This is test" and save.

    Notice that after the entry is saved, and when you refresh the view, the description has the word "Hello" appended to it.

Example 3: Automatically Put all Field Text into CAPS after Editing (When Row Turns Green)

  1. Open the Client Trigger view under: Admin Views -> Project Essentials -> Client Triggers

  2. Add the following new entry:

    Event

    accept|my_project/my_sType3

    Callback

    my_script_folder/my_client_side_script3

  3. Open the Script Editor (keyboard short-cut is "9") and create the following entry:

    Script Path

    my_script_folder/my_client_side_script3

    script type

    javascript

    code

    (see code below)

  4. Go to the view of the sType my_project/my_sType3.

  5. Refresh the tab if the view is stale.

  6. From the code example provided, modify an entry's name field. Change the text in the name field to "Tester" and the row should turn green. Be sure to save the change.

    Notice that after the entry is saved, the text in the name field will now appear as "TESTER".

Example 4: Look at Name Values in Table through a Lookahead and Pop Up a Form with Details

  1. Open the Client Trigger view under: Admin Views -> Project Essentials -> Client Triggers

  2. Add the following new entry:

    Event

    lookahead|my_project/my_sType4

    Callback

    my_script_folder/my_client_side_script4

  3. Open the Script Editor (keyboard short-cut is "9") and create the following entry:

    Script Path

    my_script_folder/my_client_side_script4

    script type

    javascript

    code

    (see code below)

    NOTE: The code below is an example written to look for names of people in an sType table and pop up a form with details about the person. The details form would be created in the Custom Layout Editor. In the example, the view is called my_project.name_detail.popup. Ensure that all values that should be displayed as part of the details in the form are also pulled from the sType table i.e. age.

  4. In order to have a lookahead that will look at the my_sType4 table, a lookahead must be built within a custom view i.e. my_views/lookahead_form in the Custom Layout Editor (this will be a different view from the aforementioned name details form). An example of the code required to create this view is shown below.

    HTML Tab in Custom Layout Editor for New View

  5. Go to the my_views/lookahead_form in Custom Layout Editor and click on the "Test" button to test the fucntionality of the view. The view can also be added to the sidebar.

  6. In the view, begin typing a name. A list of different name values from the my_sType4 table should appear in a drop down from the lookahead.

  7. Clicking on one of the values in the drop down of the lookahead will then pop up the my_project.name_detail.popup with all of the values from the external system.