MultiValue Databases - CRUD Remote Key Custom Code Example

This is an explanation and example of customisation of the CRUD code required to support Remote Keys for MultiValue Databases in Evoke. This section is not required for SQL databases.
The image on the left shows the list of objects (files) in the database. EVOKE.CRUD.BP will have been created and updated to include the standard base and custom versions of CRUD for each Database Entity.
To explain the changes needed when using Remote Keys we will use the Organization and Contacts Entities in the Sales_Order_Processing app design, as shown in the image on the right. Remote Keys are fully explained in the using MultiValue Databases section. In summary, a record may hold a single or multivalued list of keys linking the record to one or more records in another file. Remote Key means the keys may be found in records in another file to link back to this record. In this example, one or more Contacts records are associated with each Organization record (i.e. the contacts at this company (organization))
Both the Organization Entity and Contacts Entity have CRUD files in EVOKE.CRUD.BP (in our example base files EV.CRUD.CONTACT and EV.CRUD.ORGANIZATION and custom files EV.CRUD.CONTACT.CUSTOM and EV.CRUD.ORGANIZATION.CUSTOM).

Customising the CRUD code to support remote keys

In this example, because the Contacts file (object) contains the keys of the Organization that the Contact records are associated with (holds the Remote Key) we need to add the small amount of DataBasic (customise) the EV.CRUD.CONTACT.CUSTOM file.

If you click on the image on the right it will open a larger version of the image.
Under the "CASE ACTIONTYPE = "Select"" statement and immediately after the "BEGIN CASE" statement (see line 40 in the image), you will need to add similar DataBasic to that shown below.

In this example code:.

  • Line 41 - "Organization Contacts" - Organization is the Entity that declares it has associated records identified by keys held remotely and Contacts is the Entity where the Remote Keys are held. The Key is held in attribute position 1 of the Contacts file (object) as defined in the data mappings (see image top right).
  • Line 45 - "BY FULLNAME WITH ORGID =" - ORGID is the name of the attribute in the Contact file (object) where the Organization record key is held and FULLNAME is the attribute in the Contact file that will be used to order/sort the Contact records identified to have the ORGID equal to the Organization record key and returned.
  • Lines 52, 53, 54 "CONTACTDATA" and "CONTACTFILE" - CONTACTFILE is [Entityname]FILE and CONTACTDATA is [Entityname]DATA (in this example the entity name in both cases is CONTACT).



Download and open a notepad file with this code snippet in - Download Code Snippet.