I have a doozy scenario here. With some AMPscript help, using lookuporderedrows i have a cloud page with rows presented in a table. In this table there will be two input fields which i want passed to a DE along with other attributes when it is submitted. I am using InsertDE in the handler page
Where there is a single row in the table, when i submit the values are passed however when there are multiple rows it is throwing a 500 resource error.
I have been reading Adam's solution here but i am not getting the desired outcome. How can I add multiple rows to a data extension?
Below is some screenshots of a single row table and multi row table in Cloud page.
Code in my handler
%%[
var @date, @reading
set @date = RequestParameter('date')
set @reading = RequestParameter('reading')
set @Serial = RequestParameter('serial')
set @ICP = RequestParameter('icp')
set @Meter = RequestParameter('meter')
set @Reg = RequestParameter('reg')
if RequestParameter("submitted") == "submitted" then
InsertDE('Consec_responses',"SERIAL",@Serial,"ICP",@ICP,"DATE",@date,"METER",@Meter,"REG",@Reg,"READING",@reading)
endif
]%%
Updated code in my handler after reading Adam's solution Note: Serial is a unique ID created at Send_De which is being passed from the email.
%%[
set @date = RequestParameter('date')
set @reading = RequestParameter('reading')
set @Serial = RequestParameter('serial')
set @ICP = RequestParameter('icp')
set @Meter = RequestParameter('meter')
set @Reg = RequestParameter('reg')
set @Set_of_rows = Lookuprows ("Consec_Send_DE", 0, "PARTY_CODE, METER, ADDRESS, ICP, REG, SERIAL")
set @Number_of_rows= RowCount(@Set_of_rows)
FOR @i = 1 TO @Number_of_rows DO
SET @row = Row(@Set_of_rows,@i)
SET @ud =UpdateDE("Data_extension_city",1,"ID",@id,"Counter",@i)
if RequestParameter("submitted") == "submitted" then
InsertDE('Consec_responses',"SERIAL",@Serial,"ICP",@ICP,"DATE",@date,"METER",@Meter,"REG",@Reg,"READING",@reading,"Counter",@i)
NEXT @i
endif
]%%