Server-side Action Scripting

Description

Server-side action scripting is used in components to perform various sever-side tasks, such as submitting data to tables or validating secruity values.

As we saw in Genies for the UX Component, server-side Action Scripting can generate code for several major scenarios appropriate for the dialog afterDialogValidate and onDialogInitialize event handlers:

images/server-side_actions_select_an_action.png

In addition to the action to save the data in a database (note that subscribers can display a fade out confirmation message to the user if the data was successfully saved when the user clicks the Submit button)

images/save_submitted_data_to_tables.png

it can also create an action to send an email

images/send_email_message_ssa.png

and an action to populate the Dialog from one or more tables.

images/populate_dialog_with_data.png

See video "Populating a Dialog with Data from One or More Tables" Part 1 and Part 2 for more details. For all videos go to www.alphasoftware.com/videos

Save Submitted Data To Tables - SQL - Geocoding Addresses

  • Subscription feature

    When you save a record, you can automatically geocode addresses in the data at the same time the record is saved. This option only applies to SQL tables. For example, assume that the Dialog prompts for an address, city, state, postal code and country field and that the table to which the Dialog is bound has a latitude and longitude field.

    When the record is saved after edits, or a new record is added you can automatically geocode the address in the address fields and get the latitude and longitude for the address and store those values in the table's latitude and longitude fields.

  • When you edit the Server Side action to save data to tables, you will see the additional properties for Geography Fields. This is where you can define that you want to geocode addresses when the record is saved.

    images/saveRecordDialog_geographyfields.jpg

Save Submitted Data To Tables - SQL - Compute Geography Field from Latitude/Longitude Values

  • Subscription feature

    If a table has a Geography/Geometry field, when you edit the table and change either the latitude or longitude value on which the Geography/Geometry field is based, you can automatically compute a new value for the Geography/Geometry field. Encoding the Geography/Geometry field value is important if you want to do Geography searches on your data.

Security Actions

The dialog includes Action Scripting options in the Server-side events to manage user information in the web security system. These action scripts include field mapping to allow the use of any field name in the dialog for the security fields.

Only security fields that are active in the current security configuration are shown in the genie. There are three actions available.

  • Load Web Security Values

    Allows you to load data for a particular user from the Security Framework into controls in a Dialog component.

    images/SecurityActionScriptGenie.png
  • This will populate the controls with data from the web security system based on some user value passed to the action. It is added to the onDialogInitialize Server-side event. The value to identify the user can be passed to the action as a session variable, request variable, component rtc variable, or as an argument.

    images/SelectSecurityFindVar.png
  • The value can be the userid, user identifier (guid), or ulink value associated with the record. It is recommended in Alpha Anywhere to use the security userid as the linking value to any external user table. The security userid value can be added to the external table to find a user record in that table.

    The action returns a number of values, including the security value in each control as e.control.<fieldname>.

  • Validate Web Security Values

    Allows you to validate data before saving it back to the Security Framework tables.

    This will validate the values that will be saved in the web security system. It is added to the dialogValidate Server-side event. The validation is based on the security settings and will return a number of values, including dialogValidate.hasError. If other events have security action scripting defined, the option Load Saved Values on the genie will load the field mapping from the other event.

  • Save Web Security Values

    Allows you to save submitted data to the Security Framework tables.

    This will save the values to the web security system. It is added to the afterDialogValidate Server-side event. The action returns a number of values, including the security value saved for each control as rtc.data.<fieldname>. If other events have security action scripting defined, the option Load Saved Values on the genie will load the field mapping from the other event.

Post-creation work with Server-side Action Scripts

Once you have created a server-side action you can edit it and convert it to Xbasic. You can also look at the variables exposed by the action.

images/ss_action_scripting_after_the_fact.png