DCR Example

In the following example, we utilize the same customer information that was utilized in the DECS examples earlier. This time, however, we're going to directly link the CustKey form to a back-end data source.

First, if you followed the DECS examples earlier, you must go into the DECS Administrator and turn off any activities that are linked to the CustKey form.

Also, we've slightly altered the CustKey form:

  1. We added a text field to the CustKey form called NotesKey, and set it to a formula that generates a simple unique key. Add this field, call it NotesKey, and make it computed when composed . Set its formula to @Unique . You'll need to add a column to the back-end database (char(11)) and populate it to support this key. (Assuming that you have any data in your back-end database from the DECS example earlier, you can just wipe it out and start over with this example.) You should also add an index on that column. The reason for doing this is that having a unique key that never changes is better than using the customer name as in the DECS examples earlier. So, we're getting a little more advanced here, but the exercise will be profitable.
  2. We limited this form's data fields to Cname through Czip, as in the original example. If you changed it, it shouldn't bother anything, but just so you know that's what is being dealt with here.
  3. In this example, the Notes system is the primary controller of the customer data, so data will be created, updated, and deleted from Notes.

Given these changes, you must follow these steps:

  1. In the customer database, make a new DCR. We used the name DCR6, and gave it no alias for this exercise.
  2. Class will be RDBMS and Type will be ODBC.
  3. Username and password can be left blank if your ODBC driver already has it built in to the server side, or you can enter one here. We used decs for the username.
  4. Use the same data source as you did earlier (CustomerR6 or whatever you named yours).
  5. The Object will be a Table.
  6. The Name will be CustMain (or whatever you named your table on the back end).
  7. Leave all defaults on the second tab as they are.
  8. Open the CustKey form and select the default DCR and tables to use for this form.
  9. Open the properties on the NotesKey field you made in step 1.
  10. Check the External Data Source option.
  11. Click the Browse button and map this NotesKey field to the back-end NotesKey field (or whatever you called it). Make sure that this field is marked as a key field.
  12. Next open all the other fields on the form, repeating the procedure in step 11, but selecting Data Field instead. Do not select Store Data Locally.
  13. Because we want to store the documents in Notes with meaningful names , go back to the Cname field. On its Field Properties, do select Store Data Locally.
  14. The last step is to go back to the Database Properties and select Allow Connections to External Databases Using DCRs. Remember that you are prompted with the warning that the change won't take effect until the database is next openedmeaning you have to get out and go back into it.

    Now, if you create a new CustKey document and save it, its data will be stored in the back-end system. Additionally, if you open the document, it will pull the data from the back-end system as well. You can also delete it.

Категории