Bedingte Anweisung (if, then, else) conditional-instruction
Die bedingte Anweisung (if, then, else) wird im erweiterten Editor unterstützt. Sie ermöglicht die Definition komplexerer Ausdrücke. Sie umfasst die folgenden Elemente:
- if: die Bedingung, die zuerst ausgewertet werden soll.
- then: der auszuwertende Ausdruck, falls das Ergebnis der Auswertung der Bedingung wahr ist.
- else: der auszuwertende Ausdruck, falls das Ergebnis der Auswertung der Bedingung falsch ist.
if (<expression1>)
then
(<expression2>)
else
(<expression3>)
<expression1> muss einen booleschen Wert (boolean) zurückgeben.
<expression2> und <expression3> müssen denselben Typ oder kompatible Typen aufweisen. Folgende Signaturen und zurückgegebene Typen werden unterstützt:
boolean,boolean : boolean
dateTime,dateTime : dateTime
dateTimeOnly,dateTimeOnly : dateTimeOnly
decimal,integer : decimal
integer,decimal : integer
integer,decimal : decimal
duration,duration : duration
string,string : string
listBoolean,listBoolean : listBoolean
listDateTime,listDateTime : listDateTime
listDateTimeOnly,listDateTimeOnly : listDateTimeOnly
listDateOnly,listDateOnly : listDateOnly
listDecimal,listDecimal : listDecimal
listInteger,listInteger : listInteger
listString,listString : listString
Verwendung
Mit der bedingten Anweisung können Sie den Workflow der Journey optimieren, indem Sie die Anzahl der Bedingungsaktivitäten reduzieren. Beispielsweise können Sie innerhalb derselben Aktionsaktivität zwei Alternativen für eine Felddefinition angeben, wobei nur ein Bedingungsausdruck verwendet wird.
Beispiel für eine Aktionsaktivität (für ein Feld, das eine Zeichenfolge als Ergebnis der bedingten Anweisung erwartet):
if (startWithIgnoreCase(@event{eventiOSPushPermissionAllowed.device.model}, 'iPad') or startWithIgnoreCase(@event{eventiOSPushPermissionAllowed.device.model}, 'iOS'))
then
('apns')
else
('fcm')
This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.
For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.
- TL;DR: This page explains the
if / then / elseconditional instruction available in the Journey advanced expression editor, including syntax rules, supported type combinations, and a practical usage example.
Intents:
- Write a conditional expression using
if,then, andelseto return different values based on a boolean condition - Reduce the number of condition activities in a journey by embedding inline conditional logic within a single action activity
- Determine which data type combinations are valid for the
thenandelsebranches - Apply the conditional instruction to route push notification tokens to either APNS or FCM based on device model
Glossary:
- Conditional instruction: An
if / then / elseexpression construct in the advanced editor that evaluates a boolean and returns one of two expressions (product-specific) - Advanced expression editor: The Journey Optimizer interface for writing complex expressions used in conditions, wait activities, and action parameter mapping (product-specific)
Guardrails:
- Parentheses are required around all expressions in the
if,then, andelseclauses - The
ifclause (<expression1>) must return a boolean type - The
thenandelseexpressions (<expression2>and<expression3>) must have the same type or compatible types (e.g.decimalandintegerare compatible,stringandintegerare not) - Not all type combinations are supported — only the pairs listed in the supported signatures table are valid
Terminology:
- Canonical name: Conditional Instruction — Acronym: none — variants: if/then/else, ternary-style condition
- Synonyms: “conditional instruction” = “inline condition” = “if-then-else expression”
- Do not confuse: conditional instruction (inline expression) ≠ Condition activity (a journey canvas node)
FAQ:
- Q: Does the
ifclause need to be wrapped in parentheses? — Yes, parentheses are required around all expressions including the condition in theifclause. - Q: Can I use
if / then / elseto return a number from one branch and a string from another? — No;<expression2>and<expression3>must have the same or compatible types. - Q: How does the conditional instruction reduce journey complexity? — It lets you specify two field value alternatives within a single action activity using one expression, avoiding a separate Condition activity node on the canvas.
- Q: What type does the conditional instruction return if both branches are strings? — It returns a
string. - Q: Can
if / then / elsebe used to select a push notification channel? — Yes; for example, evaluating the device model to return'apns'for Apple devices or'fcm'for others.