我正在尝试使用ampscript对精确目标中的两个不同数据扩展进行查找。请找到我正在尝试的示例代码。
%%[
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循环?
有没有人遇到过类似的问题?请告诉我。
答案 0 :(得分:1)
据我所知,ampscript没有中断运算符。
在这种情况下,我会设置一个布尔值,在每个循环开始时检查为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
]%%
答案 1 :(得分:1)
%%[
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
]%%