Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

IF/ELSE AMPscript ステートメント内で「次の値を含む」演算子を使用する

公開日: Oct 13, 2022
説明

AMPscript では IF/ELSE ステートメントにネイティブの「contains」機能がありませんが、IndexOf() 関数を使用することで特定の値が含まれているかを判定できます。例えば、文字列が「Indianapolis」を含む場合に特定のメッセージを返す方法を解説します。AMPscript 構文ガイドや IndexOf() 関数の詳細も参照してください。

解決策

IF/ELSE ステートメントにおける AMPscript 関数 IndexOf() の構造例

%%[ 
Var @String, @Value, @Output 

/* Set the value to check */ 
Set @Value= "Indianapolis" 

/* Set the string to check */ 
Set @String = "Welcome to Indianapolis, we hope you enjoy your stay!" 

/* Does it match; ; if no match, output of IndexOf(1,2) will be "0" */ 
if IndexOf(@String,@Value) > 0 then 
    Set @Output = "How was your stay in Indianapolis" 
else 
    Set @Output = "Where would you like to stay?" 
endif 

]%% 
<!-- Within the body of your email, you can print out the variable here -->
%%=v(@Output)=%%

 

関連する開発者ドキュメント

ナレッジ記事番号

000386572

 
読み込み中
Salesforce Help | Article