LogoLogo
HomepageYouTube ChannelInstall from the AppExchange
  • Home
  • Dynamic Components
  • Flow Components
  • Experience Components
  • Projects
  • 👋Welcome
  • Getting Started
    • Product Tour
    • Quickstart Tutorial
    • Understanding The Essentials
      • Component Builder
      • Component Visibility
      • Target Page Object
      • Using Variables and Component Data
      • Publishing your Dynamic Components
      • Dynamic vs. Flow Components
    • Avonni Components App
      • Accessing the App
      • Folders
      • Templates
      • Version management
    • AppExchange Listing Page
    • Installation & Licenses Management
  • Tutorials
    • Projects
    • Components
      • Calendar
        • How to Create Events Quickly by Dragging
        • How to Add an Edit Action to Calendar Events
        • How to Add a New Event Button to the Calendar Header
        • How to Customize the Right-Click Menu
        • How to Reschedule Events with Drag and Drop
      • Columns
        • Creating a Responsive 3-Column Layout
      • Data Table
        • How to customize Data Table style
        • How to make a field editable
        • How to add clickable buttons
        • How to color-code badges
        • How to export data
        • How to configure search
        • How to set columns visibility
      • Kanban
        • Saving Changes on Drag-and-Drop
      • List
      • Metric
      • Record Detail
        • Saving Changes
    • Interactions
      • How to create an interaction to navigate to an object page
      • How to create an interaction to navigate to a record page
      • How to Pass Multiple Selected Records from a Dynamic Component to a Screen Flow
    • Reactive Components
      • Reactive Map and Data Table
      • Master-Detail Relationship with Data Tables
      • Vertical Tabs with Reactive Data Table
    • Style
      • How do you add space or a break between sections or fields?
    • Tips and Tricks
      • Using the Dynamic Component component
  • Component Builder
    • Overview
    • Configuring Components
      • Properties
      • Fields
      • Style
    • Data & Interactions
      • Data Sources
        • Manual
        • Picklist
      • Resources
        • Constant
        • Formula
        • Nested Queries
        • Query
        • Variable
      • Interactions
        • CRUD from Record Variable
        • Download
        • Execute Flow
        • Navigate
        • On Load
        • Open Alert Modal
        • Open Confirm
        • Open Dynamic Component Dialog
        • Open Dynamic Component Panel
        • Open Flow Panel
        • Open Flow Dialog
        • Show Toast
    • Advanced Topics
      • Undo / Redo
      • Copy and Paste
      • Keyboard Shortcut
  • Components
    • Explore All Components
    • Accordion
    • Alert
    • Audio Player
    • Avatar
    • Avatar Group
    • Badge
    • Barcode
    • Blockquote
    • Button
    • Button Group
    • Button Icon
    • Button Menu
    • Button Stateful
    • Calendar
    • Camera 🆕
    • Card
    • Carousel
    • Chart
    • Checkbox
    • Checkbox Button
    • Chip Container
    • Color Picker
    • Columns
    • Combobox
    • Container
    • Counter
    • Data LWC Container
    • Data Table
    • Date Picker
    • Date
    • Date Range
    • Dual Listbox
    • Dynamic Component
    • Formatted Address
    • Formatted Name
    • Formatted Value
    • Header
    • Icon
    • Icon Picker
    • Illustration
    • Image
    • Input Color
    • Input Date
    • Input Pen (Signature)
    • Input Text
    • Kanban
    • List
    • LWC Container
    • Map
    • Media Object
    • Metric
    • PDF Viewer
    • Pivot Table
    • Progress Bar
    • Progress Circle
    • Progress Indicator
    • Rating
    • Record Detail
    • Relationship Graph
    • Scope Notification
    • Section
    • Separator
    • Slider
    • Status
    • Tabbed Container
    • Tabs
    • Text
    • Text Area
    • Timeline
    • Toggle
    • Tree
    • Vertical Visual Picker
    • Video Player
    • Visual Picker
    • Visual Picker Link
  • Help
    • Contact Support
    • Security
    • Performance Guide
    • Deployment Process
    • Release Notes
    • Report Bugs
Powered by GitBook
LogoLogo

Company

  • About Us
  • Pricing

Policies

  • Privacy Policy
  • Terms of Service
On this page
  • Overview
  • Available Interactions
  • How Record Operations Work: Using Record Variables or Page Context
  • 1. Working with a Specific Record Variable
  • 2. Working with the Current Page's Record Context ($Component.record)
  • Example: Building a Custom Form to Create a New Lead
  • Scenario
  • Setup
  • Result
  • Important Considerations
  • In Summary

Was this helpful?

  1. Component Builder
  2. Data & Interactions
  3. Interactions

CRUD from Record Variable

Last updated 12 days ago

Was this helpful?

The Avonni Dynamic Components provide a set of interactions that allow you to perform CRUD (Create, Read, Update, Delete) operations on Salesforce records directly. These interactions operate on Record Variables that you define within your Dynamic Component.

Overview

These interactions are not typically used with components that have built-in data binding and automatic updates (like Data Table, List, Kanban, Map). Those components handle data updates through their data source configurations. Instead, the CRUD interactions are most valuable when:

  • Working with Individual Records: You need to create, update, or delete a single record based on user actions or other logic outside the context of a repeating list.

  • Building Custom Forms with the : When creating a bespoke form for creating a new record or editing an existing one. This method gives you complete control over layout and which fields are presented as individual input components.

  • Combined with "": You want to retrieve a record's data when a component loads, modify it, and then save the changes.

  • Complex Scenarios: More complex scenarios require fine-grained control over record manipulation.

Available Interactions

  • Create from Record Variable: Creates a new Salesforce record using the data in a Record Variable.

  • Update from Record Variable: This method modifies an existing Salesforce record, updating it with the data in a Record Variable.

  • Upsert from Record Variable: Creates or updates a new record.

  • Delete from Record Variable: Deletes a Salesforce record. Use this with extreme caution!


How Record Operations Work: Using Record Variables or Page Context

1. Working with a Specific Record Variable

This approach is common when you are:

  • Building custom forms to create new records.

  • Editing a record that is not the main record of the page (e.g., editing a related record loaded into a variable).

  • Needing a separate "working copy" of record data before saving.

The process is:

  • a. Define a Record Variable: In the Resources panel, create a Variable resource. Set its Data Type to Record and specify the Salesforce Object API Name (e.g., Account, Contact, My_Custom_Object__c). Give it a clear API Name (e.g., accountToEdit, newContactForm).

  • b. Populate the Record Variable: You need to get data into this Record Variable. This can happen through:

    • User Input (for Creates/Updates): Place individual input components (Text Input, Number Input, Picklist, etc.) on your canvas. You can easily do this by dragging fields from the Fields Tab (which will show fields based on your accountToEdit Record Variable). These input components become automatically bound to the fields of your Record Variable (e.g., {!accountToEdit.Name}, {!accountToEdit.Industry}). As the user types or makes selections, your accountToEdit variable is updated.

    • "On Load" > "Get Records" (for Updates/Deletes of specific/related records): Use an "On Load" interaction on your component to fetch a specific record (e.g., a related record's details) and store the result directly into your Record Variable.

    • Other Interactions: This variable could also be populated by a flow ("Execute Flow" action with output mapping) or a "Set Variable Value" action.

  • c. Trigger the Record Operation: Add an interactive component (usually an Avonni Button) and configure an On Click (or other relevant event) interaction.

  • d. Choose the CRUD Interaction: In the interaction settings, select the appropriate action type:

    • Create from Record Variable

    • Update from Record Variable

    • Upsert from Record Variable

    • Delete from Record Variable

  • e. Select Your Record Variable: In the action's configuration, choose the Record Variable you defined and populated (e.g., {!accountToEdit}).

  • f. Select Fields (for Create/Update/Upsert): Specify which fields from the selected Record Variable should be included in the create, update, or upsert operation.

2. Working with the Current Page's Record Context ($Component.record)

This approach is used when your Dynamic Component is placed on a Salesforce record page, and you want to view, edit, and save changes to that specific record.

  • b. Place on Matching Record Page: Add your Dynamic Component to a corresponding record page using the Lightning App Builder (e.g., place the component with Target Object Account onto an Account record page).

  • c. Display/Edit Fields using $Component.record: Fields dragged from the Fields Tab (which now shows fields for your Target Object) onto your canvas will typically be automatically bound to $Component.record.FieldName (e.g., $Component.record.Name). Users can view or edit these fields.

  • d. Trigger the Save Operation: Add an Avonni Button (e.g., labeled "Save Changes") and configure an On Click interaction.

  • e. Choose the Save Record Interaction: In the interaction settings, select the Save Record action type.

    • This specific interaction is designed to save any modifications made to fields bound to the current page's record context ($Component.record). It typically doesn't require you to re-select the record variable or fields, as it acts on the established page context.

Example: Building a Custom Form to Create a New Lead

This example demonstrates using a Record Variable and the "Create from Record Variable" interaction to build a custom form for creating new Lead records.

Scenario

You want a simple, focused form on an App Page or Home Page to quickly capture new Leads. It should have a specific layout and only the essential fields, rather than the standard "New Lead" button, which might have many fields.

Setup

  1. Create a Record Variable for the New Lead:

    • In your Dynamic Component's Resources panel, create a new Variable.

    • API Name: newLeadData

    • Data Type: Record

    • Object API Name: Select Lead.

  2. Build the Form Using the Fields Tab:

    • With the newLeadData Record Variable selected (or just available in your resources), go to the Component Library (left panel) and select the Fields Tab. You will see fields from the Lead object.

    • Drag the following fields onto your canvas to create input components. They will automatically bind to your newLeadData variable:

      • FirstName

      • LastName (Text Input)

      • Company (Text Input)

      • Email (Email Input)

      • LeadSource (will likely create a Combobox if it's a picklist)

    • Arrange these input components on the canvas as desired (e.g., within a Card or Columns component for better layout).

  3. Add a "Create Lead" Button

    • Drag an Avonni Button component onto the canvas below your input fields.

    • Label: "Create Lead"

    • Variant: brand (or your preferred style)

  4. Configure the "Create from Record Variable" Interaction

    • Select the "Create Lead" Button.

    • In the Properties Panel, go to the Interactions section.

    • Add an interaction to the On Click event.

    • Action Type: Choose Create from Record Variable.

    • Record Variable: Select your {!newLeadData} variable from the resource list.

    • Fields: Click "Add Field" for each field you want to save from your form (FirstName, LastName, Company, Email, LeadSource). This tells Salesforce which fields from your newLeadData variable to include when creating the new Lead record.

  5. Add Feedback (Optional but Recommended)

    • Still within the "On Click" interaction of the Button, after the "Create from Record Variable" action, click "Add Action" again.

    • Action Type: Show Toast.

    • Configure Toast:

      • Title: Success

      • Message: New Lead created successfully!

      • Variant: success

Result

When a user fills out the custom form:

  1. The input components (Text Inputs, Combobox) directly update the fields within the newLeadData Record Variable in real-time (due to the binding created when dragging from the Fields tab).

  2. When the user clicks the "Create Lead" button, the "Create from Record Variable" interaction takes all the data currently in the newLeadData variable and uses it to create a new Lead record in Salesforce.

  3. The success toast message then appears.

This example clearly shows:

  • Defining a Record Variable for a new record.

  • Populating that Record Variable using input fields bound via the Fields Tab.

  • Using the "Create from Record Variable" interaction to save that data to Salesforce

Important Considerations

  • Record Variables are Essential: These CRUD interactions require Record Variables.

  • Data Binding for Input: Use data binding to connect Input components to the fields of your Record Variable.

  • Error Handling: Consider adding error handling (e.g., using the "On Error" event of the "Execute Flow" interaction if you're using a Flow for more complex logic).

  • Permissions: Users need the appropriate Salesforce permissions (Create, Edit, Delete) on the relevant objects.

  • Use the Delete Action with caution: Use the delete action carefully.

In Summary

Avonni Dynamic Components provides a powerful way to interact with Salesforce data using Record Variables and CRUD interactions. These features allow you to build sophisticated data management capabilities without writing code, making it ideal for creating custom forms and updating related records.

a. Select Target Page Object: In your Dynamic Component's Settings (gear icon ⚙️), define the (e.g., Account). This crucial step tells your component it's operating in the context of that Salesforce object.

"On Load" for Retrieval: Use with "Get Records" to fetch existing record data.

Fields Tab
On Load
Target Page Object
the "On Load" interaction