You can use scripting to perform more complex data manipulation on an enterprise system. In this example, you can see how to add some simple script to button fields to do basic database operations, including moving to the first, previous, next, and last records, adding new records, updating existing records, and deleting records.
Note: This example is based on a particular database and configuration that is not included in the LiveCycle Designer ES samples. The example is intended as a reference for creating your own database lookup scripts.
1. In the Object Library palette, click the Standard category and drag eight button objects onto the form design. When you add a button object, the default control type is Regular. Accept the default setting.
4. In the Script Editor, select click from the Show list, select JavaScript from the Language list, and select Client from the Run At list.
• Previous: xfa.sourceSet.DataConnection.previous();
• Next: xfa.sourceSet.DataConnection.next();
• Last: xfa.sourceSet.DataConnection.last();
• AddNew: xfa.sourceSet.DataConnection.addNew();
• Update: xfa.sourceSet.DataConnection.update();
• Delete: xfa.sourceSet.DataConnection.delete();
• Cancel: xfa.sourceSet.DataConnection.cancel();
8. Test the form
using the Preview PDF tab. If such a form were being filled in Adobe Reader, you would have to set usage rights for the form by using LiveCycle Reader Extensions ES in order for Adobe Reader to access the database.
9. Click the different buttons to display the data associated with each record. The example shows that the Last button causes the ID, part number, description, and unit price for the last record to appear in the applicable fields.