AMPscript多个if / elseif语句抛出错误“ IF Not Closed”

时间:2019-03-31 08:16:05

标签: ampscript

我有下面的代码,但是它抛出了错误,提示If语句未使用EndIf关闭。我尝试了几种使用()的不同用法,但没有运气。非常感谢您的帮助。谢谢!

%%[

SET @CurrentCourse = Item_Group__c
SET @Location = Location__c

IF IndexOf(@Location, "Melbourne") > 0 AND @CurrentCourse == "Course 1" THEN 
SET @NextCourse = "Course A" 
SET @CurrentPermit = "Permit 1"

ELSEIF IndexOf(@Location, "Sydney" > 0 AND @CurrentCourse == "Course 1" THEN 
SET @NextCourse = "Course B" 
SET @CurrentPermit = "Permit 1"

ELSEIF IndexOf(@Location, "Perth") > 0 AND @CurrentCourse == "Course 1" THEN 
SET @NextCourse = "Course C" 
SET @CurrentPermit = "Permit 2"

ENDIF
]%%

2 个答案:

答案 0 :(得分:0)

在声明If语句之前,我似乎已经通过为IndexOf设置变量来解决问题。所以...

%%[

SET @Melbourne = IndexOf(@Location, "Melbourne")
SET @Sydney = IndexOf(@Location, "Sydney")
SET @Perth = IndexOf(@Location, "Perth")

IF @Melbourne > 0 AND @CurrentCourse == "Course 1" THEN 
SET @NextCourse = "Course A" 
SET @CurrentPermit = "Permit 1"

ELSEIF @Sydney > 0 AND @CurrentCourse == "Course 1" THEN 
SET @NextCourse = "Course B" 
SET @CurrentPermit = "Permit 1"

ENDIF
]%%

答案 1 :(得分:0)

如果在“悉尼”之后,您似乎第一个缺少括号。

ELSEIF IndexOf(@Location,“ Sydney”>