我正在尝试使用ampscript在确切的target中查找两个不同的数据扩展。请找到我正在尝试的示例代码。
%%[
Var @rows
Set @rows=LookupRows("DataExtensionOne","Lead Owner","Nick")
FOR @y = 1 TO RowCount(@rows) DO
Set @currentRow = Row(@rows,@y)
Set @value = FIELD(@currentRow ,"LeadId")
Set @secondDERows = LookupRows("DataExtensionTwo","Gender","Male")
FOR @x = 1 TO RowCount(@secondDERows) DO
Set @currentRowInSecDE = Row(@secondDERows,@x)
Set @secValue = FIELD(@currentRowInSecDE ,"LeadId")
IF @value == @secValue THEN
Set @FirstName = FIELD(@currentRowInSecDE ,"FirstName")
/* Need to break out of the loop */
]%%If条件检查似乎失败@value == @secValue。它不会获取@FirstName的任何值。应该使用什么语句来跳出IF循环?
有没有人遇到过类似的问题?请务必让我知道。
发布于 2015-11-27 07:32:45
据我所知,ampscript没有break操作符。
在本例中,我将设置一个布尔值,该值在每次循环开始时检查为false,并在找到匹配项时设置为True。这样,一旦匹配成功,您仍然会遍历循环的其余部分,但在它们之间不会发生任何事情。
%%[
Var @rows
Set @found_result = False
Set @rows=LookupRows("DataExtensionOne","Lead Owner","Nick")
FOR @y = 1 TO RowCount(@rows) DO
if not @found_result then
Set @currentRow = Row(@rows,@y)
Set @value = FIELD(@currentRow ,"LeadId")
Set @secondDERows = LookupRows("DataExtensionTwo","Gender","Male")
FOR @x = 1 TO RowCount(@secondDERows) DO
if not @found_result then
Set @currentRowInSecDE = Row(@secondDERows,@x)
Set @secValue = FIELD(@currentRowInSecDE ,"LeadId")
IF @value == @secValue THEN
Set @FirstName = FIELD(@currentRowInSecDE ,"FirstName")
Set @found_result = True
ENDIF
endif
NEXT @x
endif
NEXT @y
]%%发布于 2016-09-24 07:26:42
%%[
Var @rows
Set @found_result = False
Set @rows=LookupRows("DataExtensionOne","Lead Owner","Nick")
FOR @y = 1 TO RowCount(@rows) DO
if @found_result == "TRUE" then
Set @currentRow = Row(@rows,@y)
Set @value = FIELD(@currentRow ,"LeadId")
Set @secondDERows = LookupRows("DataExtensionTwo","Gender","Male")
FOR @x = 1 TO RowCount(@secondDERows) DO
if @found_result == "TRUE" then
Set @currentRowInSecDE = Row(@secondDERows,@x)
Set @secValue = FIELD(@currentRowInSecDE ,"LeadId")
IF @value == @secValue THEN
Set @FirstName = FIELD(@currentRowInSecDE ,"FirstName")
Set @found_result = True
ENDIF
endif
NEXT @x
endif
NEXT @y
]%%https://stackoverflow.com/questions/28605861
复制相似问题