How is your experience with the OutSystems Community?
16
Views
2
Comments
Solved by AI
Purpose of Local Variable in Email Template ?!

What is the purpose of local variable in Email Template? 

2023-12-26 10-35-28
OutSystems Neo
Staff
Solution by AI
AI Generated

In an Email Template, a local variable is used to hold temporary data that you need only while building that email content, and not outside of the email action/template scope. Variables in OutSystems

Once the email is generated and sent (the action finishes), all local variables are destroyed.


Why use local variables in an Email Template?

Some common reasons:

  1. Formatting or combining data
    You might receive raw data in input parameters (like ManagerName, EmployeeName, etc.) and need to:

    • Concatenate Strings
    • Add prefixes/suffixes
    • Convert values (e.g., Boolean to “Yes/No”, numbers to text)

    You don’t want to change the original parameters; instead, you store the formatted result in a local variable and use it in the email body.

  2. Intermediate calculations
    When you calculate something (like a status text, a URL with query string, or a greeting message), you store the result in a local variable to reuse it in multiple places in the email content.

  3. Readability and reuse
    Complex expressions (e.g., several concatenations or conditional text) are easier to manage when you store them once in a local variable and then use that variable in the template.


Concrete Example with your scenario

From your image, your Email Template (or screen/block called Welcome) has:

  • Parameters (likely inputs):
    ManagerName, CompanyName, EmployeeName, EmloyeeEmail, EmployeeDept
  • A local variable:
    Var1

Imagine this is a Welcome Email to a new employee.

Step 1 – Define a local variable

Create a local variable in the Email Template:

  • Name: WelcomeMessage
  • Data Type: Text

Step 2 – Assign value in preparation logic

In the logic before rendering the email content (On Initialize / Preparation action of the email), do something like:

WelcomeMessage = 
    "Dear " + EmployeeName + ",<br/><br/>" +
    "Welcome to " + CompanyName + "!<br/>" +
    "Your department: " + EmployeeDept + "<br/>" +
    "Your manager: " + ManagerName + "<br/><br/>" +
    "We have sent your login details to: " + EmloyeeEmail + "."

Now WelcomeMessage holds a fully formatted HTML/text block.

Step 3 – Use the local variable in the Email Template

In the email body, instead of repeating the expression or concatenations, you simply use:

<span>{WelcomeMessage}</span>

Here:

  • ManagerName, CompanyName, EmployeeName, EmloyeeEmail, and EmployeeDept are input parameters coming from outside the email (e.g., from another action that triggers the email). Variables in OutSystems
  • WelcomeMessage is a local variable, used only inside this email template to build/display the content. Variables in OutSystems

After the email is sent, WelcomeMessage is discarded; it doesn’t exist outside the email action.


Summary

  • Purpose: Local variables in Email Templates are for temporary storage and manipulation of data while you build the email body.
  • Scope: Only inside that Email Template (or its preparation action). They disappear after the email is generated.
  • Typical usage: Combine parameters, build formatted messages, create URLs, convert values, and then bind the local variable to elements in the email content.

If you describe what you’re currently doing with Var1, I can suggest a more tailored example (e.g., building a redirect link, generating a token, etc.).

This answer was AI-generated. Please read it carefully and use the forums for clarifications
2026-09-15 12-16-56
Mohammed Sadiq

Thankyou For Sharing!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.