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
  • 1. Overview
  • 2. Use Cases
  • 3. Creating a Constant Resource
  • 4. Using a Constant Resource
  • 5. Important Considerations
  • In Summary

Was this helpful?

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

Constant

Constant resources in Avonni Dynamic Components allow you to define fixed values that can be reused throughout your component. Unlike variables, constants cannot be changed after they are initially defined. This makes them ideal for storing values that should remain consistent, such as configuration settings, default values, or lookup information.

1. Overview

A Constant resource is a named value that is set once and remains unchanged throughout the lifecycle of the Dynamic Component. This provides several benefits:

  • Centralized Configuration: Store important values in a single place, making it easy to update them without searching through multiple components or interactions.

  • Readability: Using a descriptive Constant name (e.g., DEFAULT_COUNTRY_CODE) makes your component configuration more straightforward to understand than using a hardcoded value (e.g., 'US').

  • Maintainability: If a constant value needs to change (e.g., a new default country code), you only need to update it in one place (the Constant resource).

  • Type Safety: Constants have a defined data type (Text, Number, Boolean, etc.), which helps prevent errors.

2. Use Cases

Here are some common scenarios where Constant resources are helpful:

  • Default Values: Provide default values for input fields, filters, or other component settings. Example: A default country code for an address form.

  • Configuration Settings: Store configuration options that control the behavior of your component. Example: A maximum number of records to display in a list.

  • Lookup Values: Define a set of fixed values that can be used in comparisons or calculations. Example: Status codes, category names, error codes.

  • API Endpoints (Careful Consideration): You could store an API endpoint URL as a constant, but be careful if the endpoint might change (e.g., between development, testing, and production environments). Custom Metadata Types or Named Credentials are generally better choices for API endpoints.

  • Boolean Flags: Use Boolean constants to represent fixed states or conditions. Example: IS_DEBUG_MODE (set to true or false).

  • Record Type Ids: Store Record Type Ids.

3. Creating a Constant Resource

To create a Constant resource in your Avonni Dynamic Component:

  1. Open the Resources Panel: Click the Resources button (usually located in the page editor or component panel).

  2. Create a New Resource: Click the button to create a new resource (often a "+" icon or a button labeled "New Resource").

  3. Select "Constant": Choose "Constant" as the resource type.

  4. Configure the Constant:

    • API Name: Enter a unique identifier for the constant. Use a descriptive name that follows a consistent naming convention (e.g., DEFAULT_COUNTRY_CODE, MAX_LIST_ITEMS). This name is how you'll reference the constant in your component. The API name must be unique.

    • Description (Optional): Provide a brief description of the constant's purpose. This is helpful for documentation and maintainability.

    • Data Type: Select the appropriate data type for the constant:

      • Boolean: true or false.

      • Date: A date value (e.g., 2024-07-26).

      • Date/Time: A date and time value (e.g., 2024-07-26T14:30:00Z).

      • Number: A numeric value (integer or decimal).

      • Record: Used to store a reference to a Salesforce record, typically by its ID. You will generally not define all the fields of a record here. Instead, you'll store the record's 15 or 18-character ID.

      • Text: A string of text.

    • Value: Enter the initial and only value for the constant. This value cannot be changed after the constant is created. The value provided must match the data type.

4. Using a Constant Resource

Once you've created a Constant resource, you can easily reference it throughout your Dynamic Component's configuration. You don't need to type a special syntax manually. Instead, you'll select the Constant from a list:

  1. Locate the Property: In the component's properties panel (or within an interaction's settings), find the property where you want to use the Constant value. This might be a filter value, a component's default value, a text field's content, etc.

  2. Select the Resource: Look for a dropdown list, a selection button, or an icon (often a variable/resource icon) next to the property. This indicates that you can choose a dynamic value. Click it.

  3. Choose Your Constant: The available resources (variables and constants) will be displayed. Select your Constant resource from the list. The system will automatically insert the correct reference to the Constant. It's generally displayed between curly braces { }.

Examples:

  • In a Filter: You're configuring a filter on a Data Table. You want to filter by Country. Instead of typing 'US', you click the resource selection button next to the "Value" field, and choose your DEFAULT_COUNTRY_CODE constant from the list.

  • In a Component Property: You're setting the default value of a Text Input component. Instead of typing the default value directly, you click the resource selection button and choose your Constant.

  • Conditional Visibility: If you created a constant named SHOW_ADVANCED_OPTIONS of type Boolean, in a visibility condition, select your Constant directly from the available resources

5. Important Considerations

  • Immutability: Constants cannot be changed after they are created. If you need a value that can change, use a Variable resource instead.

  • Naming Conventions: Use clear and consistent naming conventions for your constants (e.g., all uppercase with underscores: MAX_RECORDS).

  • Data Types: Choose the correct data type for your constant.

  • Alternatives: For sensitive data or values that need to be managed outside of the component (e.g., API keys, environment-specific settings), consider using Custom Metadata Types, Custom Settings, or Named Credentials instead of constants.

In Summary

Constant resources in Avonni Dynamic Components offer a way to manage fixed values efficiently, contributing to more organized, readable, and maintainable components. Use them for defaults, configurations, and values that should not change during the component's lifecycle.

Last updated 2 months ago

Was this helpful?