MultiValue Databases - CRUD code Example

This is a simple example of customisation of the CRUD code, generated by Evoke, for MultiValue Databases. 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 exists after a) being created b) having utilities downloaded to it during the environment review and c) having "Generate repository CRUD" ticked next to each entity during a generation of the app. The object is set as including "programs" not "data"
We will open EVOKE.CRUD.BP to review the contents. This image is on the right and you can click on the image to make it larger.
This shows a list of items that equate to each of the Entities in your Evoke App design. There are two item IDs for each entity. If we take the example of the AppUser file/entity then you can see EV.CRUD.APPUSER and EV.CRUD.APPUSER.CUSTOM.
Each time your generate your app design in Evoke and tick "Generate repository CRUD" (in generate web app - Entity Mapping) next to an entity, the base CRUD file (in our example EV.CRUD.APPUSER) will be completly overwritten. However, the custom version (in our example EV.CRUD.APPUSER.CUSTOM) will remain unchanged and any custom CRUD code added to this will be preserved.

Customising CRUD code

Although the CRUD code is dataBASIC, there are different flavours for different MultiValue databases therefore the actual CRUD code you would add may vary slightly from this example.

In this example we will create a custom version of the Selection "SelectByName" associated with the APPUSER object/file. This selection is added automatically by Evoke when a new app is created and is used as part of the login authentication to find the user record of the user logging in and return password, user security level, cutlture (e.g. £ or $), etc information for the user.

First we will find the Selection "SelectByName" in the base CRUD file EV.CRUD.APPUSER. This is shown in the image on the right and all images in this selection can be clicked on to show a full size screen image.

If you are joing to customise this selection in the CRUD code then it is a good idea to copy the original, generated selection from the base CRUD file and paste it into the CUSTOM CRUD file and then customize it as you require.

Copy from line 125 ' CASE DataIn<1> = "SelectByName"' to the 'END' statement on line 171.

Now we will open the custom CRUD file EV.CRUD.APPUSER.CUSTOM
You should be able to see (image left) that under the Case Actiontype = "Select" there is an example of custom CRUD code for a selection. This is included as an example in each Custom CRUD file as an aide or reminder of where to add custom code.

In our example we will add the selection we copied from the base CRUD to the Custom CRUD above line 42.

Note: The Custom CRUD code will be interogated first to see if the selection is available in this code, if it is it will run the DataBASIC it finds and then return to the Base CRUD code. As the selection is also in the base CRUD code would also be run! Therefore, it is very important that the last line of your custom CRUD code is:    ActionCompleted = TRUE   as this will ensure that the Base CRUD Code is not run.

You can now customise your selection in your custom CRUD code as you wish.