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:
the example model left Mesage model; middle MesageTag; right Tag. all connected by HasMany relationships from the outside models to the MesageTag Model

Page Builder

Create Form

  1. Drag and drop a create form on the page. Select the model but don’t include the messageTag property (bridge model).
  2. Drag a multi auto-complete component and drop inside the create form.
  3. Disable the "Property Based Input”.
    Create Input dialog box
  4. Fill in a name for the “Action Input Variable” (for example “Tags”).
  5. 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).
    Autocomplete options, Set model
  6. Go to the create action
  7. Drag and drop an expression step beneath start. Convert the tags array to a text output as follows:
    add "{{tags}}" to the expression and add a var of tags from the input
  8. Include the selected_tags in the create record step.
  9. Drag and drop a loop function beneath the create record.
  10. Select the tags array and call the iterator tag.
    loop options. add tag as the iterator
  11. Convert the tag to a number through an expression step. (The iterator returns a text variable but we need it as a number)
    convert the tag to a number
  12. Drag and drop a create record beneath the expression step.
  13. 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.
    create the model add the relationships

The complete action:
the completed action should look like this image

Update Form

  1. Drag and drop an update form to the page. Select the Message model and the properties you want to update, except for the MessageTags.
  2. 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”.
    add the Component just like in the create form
  3. Select the Tag model and set the value to the selected tags property.
    select the model and add the correct value
  4. Go to the update action
  5. Drag and drop a loop function beneath start. Select Record.messagetags as array and choose an iterator name (in this example: tag).
  6. 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.

  7. Drag and drop another loop function and place it beneath the other loop. Select the input tags array.
  8. Drag and drop an expression steps into the loop. This will convert the tag to a number (same as in the create action).
  9. 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.
  10. 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).
  11. The last step is to configure the update record step. Map the selected tags.
    update the value of the selected tags

The Completed Update Action:
the completed action



Keywordspivot, join, relationship, relation   Doc ID133185
OwnerJoel H.GroupLow Code Solutions
Created2023-12-05 12:47:10Updated2024-02-01 12:04:58
SitesDoIT Enterprise Business Systems - Low Code Solutions
Feedback  0   0