Nationality Form: Update

Configure the nationality form to update a record.

This is the process we will follow.

UPDATE

  • Create custom variables for each field

  • Add an 'update' data source for updating a single nationality record

  • Link the key nationality record identifier to this ReST API end-point if necessary

  • Map the custom variables mapped to the form fields to the data source body fields

  • Assign this 'update' data source to the data entry form

  • Configure the update button

  • Test that we can update a nationality using the Update button

Create Custom Variables

In order to update a nationality record, we need to create custom variables for each form field so that we can send these to the ReST API.

Open the App Studio, then select the Custom Variables configurator.

  • Add a client-side custom variable called NationalityName.

  • Add a client-side custom variable called Country.

  • Add a client-side custom variable called NationalityFlag.

The new custom variables should now be displayed:

We will need to link these new custom variables to each form field, but first we will use them in a new data source to update the record.

Add an UPDATE Data Source

Open App Studio, open the Data Sources configurator, select the Nationality folder you created previously, then use the add button menu to create a new request:

The Add New Request modal popup form shows asking you to name the request:

Type a meaningful name such as "Update Nationality" and click Save.

The request will be added to your tree view beneath the Nationality folder:

Edit Properties

Edit the properties in the Details tab by referencing this list of ReST API end-points.

URL

https://football-891b.restdb.io/views/UpdateNationality

It is known from the documentation that this ReST API end-point has a nationality identifier property ?ID=.

We therefore type this parameter list into the URL so that it reads:

https://football-891b.restdb.io/views/UpdateNationality?ID=

Whilst the caret is still blinking after the last character typed, click on the Insert Variable button:

This will open the following modal popup for where you should select the Nationality-ID custom variable you created previously in the Variable drop down list . Click the Select button.

The URL should now show the custom variable appended to the end:

HTTP Verb

The default GET verb/method is not correct for updating a single record using the ReST API and should be set to PATCH for this specific back-end end-point.

The request should now look like this:

Authorisation

Previously we set up security credentials at the Football folder level, so we can leave this to be set to "Inherit from parent".

We do not need to change anything else.

Body

When we are updating or creating data, we will be sending the data in the body of the request, so we configure this before sending the request to test it, using the new custom variables. Here is the empty Body tab:

We will always use the JSON body format as this gives us maximum control.

From the ReST API specification, we know that this endpoint expects data in this format:

{
    "Name": "",
    "Country": "",
    "FlagURL": ""
}

Our job is to now associate each field with the appropriate custom variable.

Put the carat inside each double quotation and use the Insert Variable button to select the respective custom variables setup above.

After all three have been inserted, the body should now look like this:

{
    "Name": "<#NationalityName#>",
    "Country": "<#Country#>",
    "FlagURL": "<#NationalityFlag#>"
}

Send Request

It is best practice to now click this button on the Details tab to send the request to the ReST API.

The problem however is that we would have to update an existing record in order to test this.

The best way of course to test this is to use the actual nationality form we created here, and link that form to this data source request, then we can test it.

Edit Form

Open App Studio, open the Forms configurator, then select the Nationality form:

Click the Edit button to open the form properties modal popup.

Data Sources

Click the Data Sources tab. There are 4 CRUD data sources lines. Click this database icon to assign the Update data source:

This modal popup form appears to allow you to select the previously created data source request. Navigate through the folder hierarchy until you locate this data source request, then click the Select button.

This Update data source request should now appear in the list of assigned data source requests:

If you ever need to remove a data source request from the list, you can use this button:

Now click the Apply button on this form, in order to persist the form properties before designing your form. The Update data source request you added should be shown in the properties list:

Form Design

Click one of the Edit buttons, either the grid row or properties panel. The form modal popup will display. Click the Design button, and select the Main Top Region tab:

Fields

Click on each of these fields in turn and assign the appropriate custom variable you added previously:

Save Form

Now save the form design using this button:

The form fields are now assigned to the new custom variables used in the body of the new data source request to update the record.

We will now configure the update button on the form.

Configure Update Button

Open App Studio, open the Forms configurator, then select the Nationality form and click the edit button. Then click the CRUD tab:

There are four mechanisms to control: Create, Read, Update and Delete.

Create

A new record can only be created from the app toolbar using the Add drop down menu:

Use this configurator to add any form to this list.

Read

Reading form data is always visible when a form is opened and a record is loaded.

Update

The update button lives together with the delete button top right on the form:

It can be hidden, its caption set and its icon set using these controls:

Delete

The delete button lives together with the update button top right on the form. It can be hidden, its caption set and its icon set using these same controls.

Apply

Apply any changes to persist them before testing.

Test

You can now test your configuration by opening the Football Industry group in the navigation bar and selecting the Nationalities item. Drill down into any nationality to open the form.

Add an X to the end of the Nationality and Country fields, or indeed click the flag and upload a new flag image. Then press the Save button. The form record update should be confirmed:

Last updated