0

I'm running a LookupRows in Marketing Cloud from a CloudPage:

%%[
if @drowcount > 0 then
set @drow = row(@drows,@i)
for @i = 1 to @drowcount do
set @dstatus = Field(@drow,"creativeRecieved")
]%%

%%=v(@dstatus)=%%<br>

%%[next @i endif]%%

(Note this is part of a bigger loop) it's finding rows on a data extension matching it with a master record using email address. It's returning 'true' or 'false' for a certain field, for as many lines as it finds. For example, if it finds 4 lines matching this emailAddress, it loops through 4 times and finds 4 trues or falses.

I would like to be able to do something if all of these come back as 'true'. What's the easiest way to do this? Can I save them as a temporary recordset and then run IndexOf over it?

3 Answers 3

1
%%[
if @drowcount > 0 then
    set @allTrue = true
    for @i = 1 to @drowcount do
    set @drow = row(@drows,@i)
    set @dstatus = Field(@drow,"creativeRecieved")

    if @dstatus == false then
        set @allTrue = false
    endif
]%%

%%=v(@dstatus)=%%<br>

%%[
    next @i 

    if @allTrue == true then
        //do something
    endif
endif
]%%
2

The two simplest ways to accomplish this are:

Using a string and CONCAT each result

Example below:

%%[ if @drowcount > 0 then
set @drow = row(@drows,@i)
for @i = 1 to @drowcount do
set @dstatus = Field(@drow,"creativeRecieved")

IF EMPTY(@statusString) THEN

  SET @statusString = @dstatus

ELSE

  SET @statusString = CONCAT(@statusString, " | ", @dstatus)

ENDIF
]%%

%%=v(@dstatus)=%%<br>

%%[

NEXT @i

IF INDEXOF(@statusString, "True") == 0 THEN

  /* FALSE only actions */

ELSEIF INDEXOF(@statusString, "False") == 0 THEN

  /* TRUE only actions */

ELSE

  /* Default actions */

ENDIF

endif
]%%

Using a Var to track status

Example below:

%%[ if @drowcount > 0 then
set @drow = row(@drows,@i)
for @i = 1 to @drowcount do
set @dstatus = Field(@drow,"creativeRecieved")

IF @tStatus != "Mixed" THEN

  IF EMPTY(@tStatus) THEN

    SET @tStatus = @dstatus

  ENDIF

  IF @tStatus != @dstatus THEN

    SET @tStatus = "Mixed"

  ENDIF

ENDIF

]%%

%%=v(@dstatus)=%%<br>

%%[

NEXT @i

IF @tStatus == "False" THEN

  /* FALSE only actions */

ELSEIF @tStatus == "True" THEN

  /* TRUE only actions */

ELSE

  /* Default actions */

ENDIF

endif
]%%
0

Thanks for the suggestions folks. In the end I simplified and went with doing two different lookuprows:

%%[
set @email = Field(@row,"emailAddress")
set @erows = LookupRows("CC_B2B_Email","emailAddress",@email)
set @erowcount = Rowcount(@erows)
]%%
Rowcount for Email: %%=v(@erowcount)=%%<br>

%%[
set @email = Field(@row,"emailAddress")
set @erowst = LookupRows("CC_B2B_Email","emailAddress",@email,"creativeReceived","True")
set @erowcountt = Rowcount(@erowst)
]%%
Rowcount for Email Done: %%=v(@erowcountt)=%%<br>

Then compared the two rowcounts - if they were the same, then I could mark them as true.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .