1

我正在尝试使用 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 循环?

有没有人遇到过类似的问题?请务必让我知道。

4

2 回答 2

1

据我所知,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
]%%
于 2015-11-26T23:32:45.273 回答
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
]%%
于 2016-09-23T23:26:42.253 回答