Step by Step: Create a Custom UI Model to Manage Child Records

Note: This sample uses a new spec type called the CustomUIModelMetadata spec, which creates a Custom UI Model that is similar to a type of feature known as data form. This content assumes you are familiar with the UI Model concepts and you have experience creating a UI Model. If you are unfamiliar with UI Models, see UI Model for Data Forms.

Overview

Batches often manage data that has a one-to-many relationships. A constituent batch record can contain many child phone records. In the case of a Food Bank Transaction Add Batch, a parent food bank transaction record can contain many child transaction detail records.

Figure: A parent transaction record can have many child detail records.

With the Food Bank Transaction Add Batch code sample as an illustration, we see below the form fields within batch's add form used to add food bank transaction header and detail records into their respective staging area tables. We can borrow the FOODITEMS form field, which contains a collection of child form field and create a Custom UI Model bases upon the collection to provide a custom dialog data entry screen used to manage the food items.

Figure: FOODITEMS FormField Collection

Figure: The Custom UI Model will receive its data from the data within the batch grid.

Step 1 -  Add a new Custom UI Model item into your UIModel Visual Studio project used to support the batch.

Figure: Add a Custom UI Model Metadata Spec into the UI Model Project

The template provides a starting point for your Custom UI Model. In the next step, we will replace these default form fields with the food item form field collection used by the batch.

Figure: You need to modify the form field tags to include the collection of items you wish to display on your dialog screen.

Step 2 -  Copy the FOODITEMS form field collection from your batch's add data form to the new CustomUIModelMetadata spec.

Tip: By ensuring the CustomUIModelMetadata spec's form field collection structure matches the structure of the batch's form field collection structure, we will set ourselves up for an elegant solution when it comes time to programmatically copy the child food item data from the batch child grid to the Custom UI model dialog screen and vice versa.

Figure: Your CustomUIModelMetadataSpec should look like this after you copy the FOODITEMS form field from the batch's add data form.

Step 3 -  Provide values for the CustomUIModelMetadata's Author and FormHeader attributes.

Step 4 -  Within the UI Model project, generate the UI Model from the CustomUIModelMetadata spec.

Tip: If you are unfamiliar with UI Models, see UI Model for Data Forms. and Custom UI Models.