Skip to main content
Question

When should a developer use a Constant in Appian instead of hardcoding a value?

A
Anonymous
June 25, 2026

Answer

A constant in Appian stores a value you can reuse across application objects such as interfaces, expression rules, process models and integrations.

You define the value once in a constant and reference it with cons!, so you don’t have to type the same value in several places.

Use a constant when a value is reused, needs to be maintained in one place, or has to be set differently in each environment.


Example: Invoice Approval Application

Take an Appian application where any invoice over $10,000 needs Senior Manager approval.


Approach 1: hardcoding (not recommended)

The developer writes the threshold straight into the expression:

if(
ri!invoiceAmount > 10000,
"Senior Manager Approval",
"Manager Approval"
)

The problem:

Say the business raises the approval threshold from $10,000 to $15,000.

If 10000 is hardcoded in several expression rules, interfaces and process models, the developer has to find and change every one of them.

That’s more maintenance work, and if one occurrence gets missed, different parts of the app apply different rules.


Approach 2: using a constant (recommended)

Create a constant:

  1. Name: INV_APPROVAL_THRESHOLD
  2. Type: Integer
  3. Value: 10000

Then reference it in the expression:

if(
ri!invoiceAmount > cons!INV_APPROVAL_THRESHOLD,
"Senior Manager Approval",
"Manager Approval"
)

The benefit:

If the threshold changes to $15,000, you update the constant’s value and nothing else.

Every expression that references the constant picks up the new value automatically.


Common uses for constants

Use case

Example

Business thresholds

cons!INV_APPROVAL_THRESHOLD

Appian groups

cons!INV_FINANCE_MANAGER_GROUP

Status values

cons!INV_STATUS_APPROVED

Document folders

cons!INV_DOCUMENT_FOLDER

Environment-specific settings

cons!INV_API_BASE_URL

Configuration values

cons!INV_MAX_RETRY_COUNT

Environment-specific constants

Constants also help when a configuration value differs between environments.

For example, an external API endpoint might be different in DEV, TEST and PROD:

Instead of hardcoding these URLs in different expressions, create an environment-specific constant such as cons!INV_API_BASE_URL.

When you deploy between environments, you set these values through an import customization file.

Important: the Environment Specific option works for primitive and Email Address constant types. Turn it on only when the value really is different in each environment.


When should you avoid constants?

Not every value belongs in a constant:

  1. Simple literals: you can hardcode values like true, false, 0 or 1 when their meaning is obvious and they aren’t business settings.
  2. User-entered values: use rule inputs or process variables instead.
  3. Business data that changes often: store it in a database or record type so you aren’t updating a constant again and again.
  4. Sensitive credentials: set up secure authentication in Connected Systems instead of putting passwords or API secrets in ordinary constants.


Reference : Appian Official Documentation – Constant Object


Check yourself

Question 1 of 3, on what the answer above covers.

  1. 1.
    An Appian application requires Senior Manager approval for invoices above $10,000. The threshold is used in multiple expression rules and process models. The business may change this amount in the future.
    What is the best approach?
JuniorInterfaces#best_practices