LCS - Creating and using a Bridge Model in Betty Blocks
Guide on bridge models and how to use them
Model Setup
To explain how to create and update a bridge model, this simple data model schema will be used:
Page Builder
Create Form
- Drag and drop a create form on the page. Select the model but don’t include the messageTag property (bridge model).
- Drag a multi auto-complete component and drop inside the create form.
- Disable the "Property Based Input”.
- Fill in a name for the “Action Input Variable” (for example “Tags”).
- Set the model to Tag. (If you didn’t set the label to “Name” in the data model, you can use the “Label for Options” on the left hand side).
- Go to the create action
- Drag and drop an expression step beneath start. Convert the tags array to a text output as follows:
- Include the selected_tags in the create record step.
- Drag and drop a loop function beneath the create record.
- Select the tags array and call the iterator tag.
- Convert the tag to a number through an expression step. (The iterator returns a text variable but we need it as a number)
- Drag and drop a create record beneath the expression step.
- Select the MessageTag model and add the properties Message and Tag. The value of Message will be the result record of the previously created message. The Tag value will be the tag_as_number.
The complete action:
Update Form
- Drag and drop an update form to the page. Select the Message model and the properties you want to update, except for the MessageTags.
- Drag and drop the multi auto-complete into the update form. Disable the “Property Based Input” and choose a name for the “Action Input Variable”.
- Select the Tag model and set the value to the selected tags property.
- Go to the update action
- Drag and drop a loop function beneath start. Select Record.messagetags as array and choose an iterator name (in this example: tag).
- Drag a delete record step into the loop. Go to the Variables tab and create a new Record variable. Choose the MessageTag model and filter on id.
- Drag and drop another loop function and place it beneath the other loop. Select the input tags array.
- Drag and drop an expression steps into the loop. This will convert the tag to a number (same as in the create action).
- Drag and drop a create record step beneath the expression step. Set the MessageTag model and map the Message and Tag values. For the Message property use Record.id and for Tag use tag_as_number.
- Drag and drop a new expression step under the loop. This step will map the tag.id’s into a text output (same as in the create action).
- The last step is to configure the update record step. Map the selected tags.
The Completed Update Action: