條件式指令(if、then、else)

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

  • if:要先評估的條件。
  • then:條件評估結果為true時要評估的表達式。
  • else:條件評估結果為false時要評估的表達式。
注意

所有運算式都需括弧。

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(@{eventiOSPushPermissionAllowed.device.model}, 'iPad') or startWithIgnoreCase(@{eventiOSPushPermissionAllowed.device.model}, 'iOS'))
then
   ('apns')
else
   ('fcm')

本頁內容