ON THIS PAGE
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Advanced Dynamic Expressions

In this section, we will prepare many increasingly complex examples of dynamic expressions to inspire you and show you some of the possibilities they unlock.

Dynamic Expressions + Automations and Notifications

Learn how to use dynamic expressions with custom views and automations to personalize workflows and enhance productivity.

  • Goal: Notify editors when an idea is rated, linking them to a custom "Rated Ideas" view.
  • Steps:
    • Create View: Filter to show only rated ideas, visible to editors.
    • Set Up Automation: Trigger notifications when ideas are rated.
    • Craft Notification: Use dynamic expressions to include the idea’s title, owner, and direct URL to the rated view.
    • Personalize View: Add a dynamic greeting with the session user's name.
  • Test: Rate an idea to confirm the notification and link work as expected.

Once live, the setup notifies editors and directs them to the rated ideas list via a clickable link in their notification tab.

Dynamic Expressions + Static Fields

Learn how to use dynamic expressions with static fields to enhance idea submissions and real-time calculations.

Goal: Create a custom score field that updates in real time based on idea interactions.

Steps:

  1. Add Static Field:
    • Create a static field (e.g., "Custom Score") in a simple form and add a tooltip for explanation.
    • Set the field type as "Number" and use context.stats.likes.total to track total likes.
  2. Use Dynamic Expressions:
    • Populate the field with real-time data using context variables.
    • Combine expressions (e.g., likes + average rating) to calculate scores.
    • Reference user-filled fields (e.g., an "Estimate" field) by ID in the expression.
  3. Incorporate Functions and Operators:
    • Add conditional logic (e.g., if the rating is below 1, default to 1).
    • Use parentheses and multipliers to prioritize values (e.g., multiply ratings by 10).
  4. Test the Setup:
    • Submit an idea and fill out the required fields.
    • Verify that the custom score updates dynamically (e.g., after rating the idea).
    • Reload to confirm real-time updates.
  5. Additional Uses:
    • Use the custom score in list views, plots, exports, and filters.
    • Optionally, override values later with automations (e.g., using "Update Idea" actions).

Outcome: The dynamic custom score field enhances sorting, filtering, and tracking by updating in real time based on user interactions.

Examples of Math Operations

  • Add two numbers
  • {{ 1 + 2 }}
    {{ sessionUser.stats.likes + 2 }}
    {{ idea.field.d4141580-66ec-4f72-b25c-6282362ed61d.value + idea.field.00c91022-050a-489d-8a9a-e9d668698ecc.value }}
  • Divide two numbers
  • {{ 1 / 2 }}
    {{ ideaCollection.stats.ideas.total / 10 }}
  • Raise a number to a power
  • {{ 2 ** 2 }}
    {{ sessionUser.stats.ideas ** 2 }}
  • Adjust the order of operations in a math formula
  • {{ (2 + 2) * 4 }}
  • Take the average of some numbers, and round to nearest whole number
  • {{ ROUND(AVERAGE(2, 3, 5)) }}
    {{ ROUND(AVERAGE(sessionUser.stats.likes, 3, 5)) }}
  • Take the largest number in a set
  • {{ MAX(1, 3, 5) }}
    {{ MAX(1, 3, sessionUser.stats.assignments) }}
  • Take the length of a word
  • {{ LENGTH("Hello") }}
    {{ LENGTH(sessionUser.name) }}

Examples of Working with Text

  • Uppercase a word
  • {{ UPPERCASE("hello") }}
    {{ UPPERCASE(translate:custom.my.translation.variable) }}
  • Truncate a word if it exceeds 10 characters
  • {{ TRUNCATE("Hi, I’d like to share with you my whole life story", 10) }}
    {{ TRUNCATE(sessionUser.name, 10) }}
  • Repeat a word three times
  • {{ REPEAT("Hi! ", 3) }}
    {{ REPEAT(ideaCollection.title, 3) }}
  • Replace the character ‘H’ in a word with ‘C’
  • {{ REPLACE("Hello", "H", "C") }}
    {{ REPLACE(sessionUser.name, "H", "C") }}
  • Remove leading and trailing whitespace from a word
  • {{ TRIM("   Hello   ") }}
    {{ TRIM(sessionUser.name) }}

Examples of Logic Operations

  • Check if a number is greater than another number
  • {{ 3 > 2 }}
    {{ sessionUser.stats.ideas > 2 }}
  • Check if a calculation is correct
  • {{ 2 + 2 == 4 }}
    {{ (2 + 2) * 4 == 16 }}
  • Check if a number is equal to another number
  • {{ 3 == 2 }}
    {{ sessionUser.stats.ideas == 2 }}
  • Check if something is not true
  • {{ !(2 + 2 == 4) }}
  • Check if all conditions are true
  • {{ 2 + 2 == 4 && 6 * 6 == 36 }}
    {{ LENGTH(sessionUser.name) > 10 && LENGTH(sessionUser.name) < 50 }}
  • Check if at least one condition is true
  • {{ 2 + 2 == 5 || 4 + 4 == 8 }}
    {{ LENGTH(TRUNCATE("Goodbye, " + sessionUser.name, 30)) < 50 || sessionUser.stats.likes > 2 }}
  • Combining AND and OR groupings
  • {{ 2 + 2 == 4 && (3 + 3 == 5 || 4 + 4 == 8) }}
  • Check if a word starts with a specific sequence of characters
  • {{ STARTS_WITH("hello", "he") }}
    {{ STARTS_WITH(translate:custom.greeting, "Greetings") }}
  • Check if a word includes a specific sequence of characters
  • {{ INCLUDES("hello", "ll") }}

Examples of Conditionals

  • Display a different word, depending on the value of a calculation
  • {{ 2 + 2 == 4 ? "Correct" : "Incorrect" }}
    {{ sessionUser.stats.likes > 10 ? "Top-contributor" : "Rookie" }}
  • Use different translation variables for different users depending on their rank
  • {{ sessionUser.rank >= 3000 ? translate:custom.admin_text : translate:custom.normal_member_text }}

By using these dynamic expressions, you can create sophisticated, personalized, and powerful logic within your workspace.

How helpful was this article?
Thank you! Your feedback helps us improve.
Oops! Something went wrong while submitting the form.