0

I am using AMPscript in an HTML paste email to update a reference DE with subscriber data on the fly so that I can use it later in the subscriber's email. I have scaled back the code below for troubleshooting. There are 16 "programs" but I am only showing 2.

%%[
/*
Insert Program details to the program details data extension so that we can reference it later in the email.
*/

/* 1. Group Fitness */
UpdateDE("Day1_ProgramDetails", 1,
        "ProgramID", 1,
        "ProgramName", "GroupFitness",
        "Image", "#",
        "URL", "#",
        "DH_Name", Concat(v(@GroupFitnessDH_FirstName), " ", v(@GroupFitnessDH_LastName)),
        "DH_Role", v(@GroupFitnessDH_RoleDescription),
        "DH_Phone", v(@GroupFitnessDH_Phone),
        "DH_EmailAddress", v(@GroupFitnessDH_EmailAddress))

/* 2. Weight Loss */
UpdateDE("Day1_ProgramDetails", 1,
        "ProgramID", 2,
        "ProgramName", "WeightLoss",
        "Image", "#",
        "URL", "#",
        "DH_Name", Concat(v(@PTDH_FirstName), " ", v(@PTDH_LastName)),
        "DH_Role", v(@PTDH_RoleDescription),
        "DH_Phone", v(@PTDH_Phone),
        "DH_EmailAddress", v(@PTDH_EmailAddress))

/*
Find which programs the member is eligible for, update ProgramDetails data extension to track which programs the member is eligible for
*/

        VAR @programs_qualified, @programs_count

        SET @programs_qualified = ""
        SET @programs_count = 0  



/* 1. Group Fitness */
        IF @Amenity_GroupFitnessStudio == TRUE THEN
            IF @programs_count == 0 THEN
                SET @programs_qualified = "1"
            ELSE    
                SET @programs_qualified = Concat(v(@programs_qualified), "|","1")
            ENDIF

            UpdateDE("Day1_ProgramDetails", 1,
            "ProgramID", 1,
            "QualifiedFlag", "TRUE")

            SET @programs_count = Add(@programs_count, 1)   
        ENDIF

/*2. Weight Loss*/
        IF @programs_count == 0 THEN
            SET @programs_qualified = "2"
        ELSE    
            SET @programs_qualified = Concat(v(@programs_qualified), "|","2")
        ENDIF

            UpdateDE("Day1_ProgramDetails", 1,
            "ProgramID", 2,
            "QualifiedFlag", "TRUE")

            SET @programs_count = Add(@programs_count, 1)   
        ENDIF
/*
Loop through to display the program areas, depending on how many the member is eligible for. The max to display is 6.
*/

        VAR @program_rowset, @program_displaycount, @i, @column_interval, @Program_ID, @Program_Lookup,  @Program_Name, @Program_Image, @Program_URL, @Program_DHName, @Program_DHRoleDescription, @Program_DHPhone, @Program_DHEmailAddress

        IF @programs_count >= 1 THEN
            SET @program_rowset = BuildRowsetFromString(@programs_qualified, "|")

            IF ROWCOUNT(@program_rowset) > 6 THEN
                SET @program_displaycount = 6
            ELSE
                SET @program_displaycount = ROWCOUNT(@program_rowset)
            ENDIF 

            SET @column_interval = 0

            FOR @i = 1 to @program_displaycount DO

                SET @Program_ID = FIELD(ROW(@program_rowset, @i), 1)
                SET @Program_Lookup = LOOKUPROWS("Day1_ProgramDetails", "ProgramID", @Program_ID)
                SET @Program_Name = FIELD(ROW(@Program_Lookup,1), "ProgramName")
                SET @Program_Image = FIELD(ROW(@Program_Lookup,1), "Image")
                SET @Program_URL = FIELD(ROW(@Program_Lookup,1), "URL")
                SET @Program_DHName = FIELD(ROW(@Program_Lookup,1), "DH_Name")
                SET @Program_DHRoleDescription = FIELD(ROW(@Program_Lookup,1), "DH_Role")
                SET @Program_DHPhone = FIELD(ROW(@Program_Lookup,1), "DH_Phone")
                SET @Program_DHEmailAddress = FIELD(ROW(@Program_Lookup,1), "DH_EmailAddress")

                ]%%

Do some HTML

%%[Next @i]%%

From the code above, I am expecting the following to happen:
1. job begins processing first email for first subscriber
2. ampscript updates Day1_ProgramDetails data extension with the data applicable to this subscriber
3. ampscript determines program eligibility based on this subscriber's data
4. ampscript loops through eligible programs and pulls data stored previously in Day1_ProgramDetails data extension
5. ampscript to display data from Day1_ProgramDetails for this subscriber
6. job sends email and repeats above steps for next subscriber.

However, for #5, instead of seeing the data applicable to "this" subscriber, I am seeing data applicable to the LAST subscriber processed in the email batch. Essentially, all subscribers in the batch will see Day1_ProgramDetails data applicable to the last subscriber processed in the batch.

Thoughts?

1 Answer 1

0

Sounds like an incorrect assumption on my part for how ampscript is compiled and processed. Excerpt below from this page: http://help.exacttarget.com/en/documentation/exacttarget/content/ampscript/how_ampscript_update_insert_and_delete_calls_are_processed_during_sends/

Instead of making several different AMPscript calls as part of an email send, the ExactTarget application takes all applicable AMPscript calls and completes them in one call at the end of the send.

You must log in to answer this question.

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