0

I'm using the following bit of code to create a series of data extensions. I'm trying to create the name from a concatenation of Job_Ref and Creative_Name from a reference database.

%%[
    /*Using this name, find how many creative_number variants it has*/
set @crs = LookupOrderedRows("UM_CreativeSplit",0,"Creative_Name ASC","Job_Ref",@name)
set @crc = Rowcount(@crs)
set @cr = Row(@crs,1)
set @cn = Field(@cr,'Creative_Name')
]%%
DE Rowcount %%=v(@crc)=%%<br>
%%[
/*CREATE THE DATA EXTENSIONs*/
For @cr = 1 to @crc do
set @dename = Concat(@name,"_",@cr)
]%%

This version just uses the loop counter number (@cr) and appends it to the name (which is set previously to this part of the code using Field(@r,'job_ref').

As you can see, before the For loop I have

set @cn = Field(@cr,'Creative_Name')

Which works correctly. However, when I use this inside the For loop, I get the following error

Error Message: Invalid object property name. Object Type: System.Int64 Property Name: Creative_Name Description: An unexpected error occurred during the execution of the page.

Why doesn't it work inside the For loop? I want to be able to cycle through these.

3
  • 1
    trying using treatascontent() function and check it. set @dename = TreatAsContent(Concat(@name,"_",@cr)) and then use Field()
    – Abhishek
    Commented Jun 5, 2018 at 10:19
  • What's the value of @name? Commented Jun 5, 2018 at 11:11
  • @AdamSpriggs - it's set earlier in the code and is static, doesn't change for the loop. I have it working now!
    – TCassa
    Commented Jun 5, 2018 at 11:13

2 Answers 2

3

You're resetting the @cr variable in your for-loop. I'd switch that to something else:

%%[

var @crs, @crc, @cr, @cn, @name, @dename

set @name = "Testing"

set @crs = LookupOrderedRows("UM_CreativeSplit",0,"Creative_Name ASC","Job_Ref",@name)
set @crc = Rowcount(@crs)

if @crc > 0 then

    set @cr = Row(@crs,1)
    set @cn = Field(@cr,'Creative_Name')
    output(concat("DE Rowcount: ", @crc, "<br>"))

    for @i = 1 to @crc do

       set @dename = Concat(@name,"_", @i)

       /* other code */

    next @i


endif
]%%
0

I found a solution - refer to the row all over again within the Field() function

set @cn = Field(Row(@crs,@cr),'Creative_Name')

This worked.

You must log in to answer this question.

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