條件式指令(if, then, else) conditional-instruction

進階編輯器支援條件式指令(if, then, else)。 它可讓您定義更複雜的運算式。 它由下列元素組成:

  • if:先評估條件。
  • then:條件評估結果為true時要評估的運算式。
  • else:條件評估結果為false時要評估的運算式。
NOTE
所有運算式都必須加上括弧。
if  (<expression1>)
then
   (<expression2>)
else
   (<expression3>)

<expression1>必須傳回​ 布林值

<expression2><expression3>必須具有相同的型別或相容的型別。 支援的簽章和傳回的型別包括:

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

使用狀況

條件式指示可讓您透過減少條件活動的數量,將歷程工作流程最佳化。 例如,在相同動作活動中,您僅能使用一個條件運算式,即可為欄位定義指定兩個替代方案。

動作活動的範例(適用於預期字串為條件指令結果的欄位):

if (startWithIgnoreCase(@event{eventiOSPushPermissionAllowed.device.model}, 'iPad') or startWithIgnoreCase(@event{eventiOSPushPermissionAllowed.device.model}, 'iOS'))
then
   ('apns')
else
   ('fcm')
recommendation-more-help
b22c9c5d-9208-48f4-b874-1cefb8df4d76