I am using the BuildRowset string to split the string and store the string in the variable, but i am taking the value manually from Data Extension attribute called Subscriber field. In that field string is stored separated by commas, I don't know how many strings are stored in that attribute.
I have tried:
%%[
VAR @Text ,@Split1, @Split2, @Split3
SET @rowset = LookupRows("raviDE","Email", "[email protected]")
SET @row = Row(@rowset, 1)
set @act=Field(@row,"subscrption")
SET @Rows = BuildRowSetFromString(@act, ",")
SET @Split1 = Field(Row(@Rows, 1), 1)
SET @Split2 = Field(Row(@Rows, 2), 1)
SET @Split3 = Field(Row(@Rows, 3), 1)
if @Split1=="bed" then
SET @acts= "checked"
endif
if @Split2=="clock" then
SET @acts1= "checked"
endif
if @Split3=="phone" then
SET @acts2= "checked"
endif
if @Split1==False then
SET @act=""
endif
if @Split2==False then
SET @act=""
endif
]%%
%%=v(@Split1)=%%</br>
%%=v(@Split2)=%%</br>
%%=v(@Split3)=%%</br>
<form id="myForm" method="post" action="http://pages.S7.exacttarget.com/page.aspx?QS=38dfbe491fab00ea0ad4b925273e8608d40bab6a35b96d3428a16f6a0f519dc7">
Email: <input type="text" name="test4" value="%%=Field(@row, "Email")=%%" /></br>
Checkbox:<input type="checkbox" name="test5" value="bed" %%=v(@acts)=%%/> A Bed
<input type="checkbox" name="test5" value="clock" %%=v(@acts1)=%%/> A Clock
<input type="checkbox" name="test5" value="phone" %%=v(@acts2)=%%/> A phone
<input type="submit" value="submit"/>
</form
>
Error Message:
An unexpected error has occurred! Error Message: Invalid index (parameter 2) passed to Row function. Index must be less than or equal to the row count. Index Value: 2 Row Count: 1 Function: Row(@Rows, 2) Description: An unexpected error occurred during the execution of the page.
How to rectify the error using Amp script?
Now I am facing another issue:
%%[/* Modify to view AMPScript <div style="display:none"> */
VAR @email, @Split1, @Split2, @Split3, @acts, @acts2, @acts3
SET @rowset = LookupRows("raviDE","Email", "[email protected]")
SET @row = Row(@rowset, 1)
set @email = "[email protected]"
if rowcount(@rowset) > 0 then
set @email = Field(@row, "Email")
endif
set @act = Field(@row,"subscrption")
SET @Rows = BuildRowSetFromString(@act, ",")
set @rowCount = rowcount(@rows)
output(concat("<br>@rowCount: ", @rowCount))
set @split1 = ""
set @split2 = ""
set @split3 = ""
set @acts = ""
set @acts2 = ""
set @acts3 = ""
if @rowCount > 0 then
if @rowCount >= 1 then
SET @Split1 = Field(Row(@Rows, 1), 1)
endif
if @rowCount >= 2 then
SET @Split2 = Field(Row(@Rows, 2), 1)
endif
if @rowCount >= 3 then
SET @Split3 = Field(Row(@Rows, 3), 1)
endif
if @Split1 == "Seasonal travel information and trip ideas" then
SET @acts= "checked"
endif
if @Split1 == "Travel Deals-monthly" then
SET @acts1= "checked"
endif
if @Split1 == "Ski Deals Seasonal" then
SET@acts2 = "checked"
endif
if @Split2 == "Seasonal travel information and trip ideas" then
SET @acts= "checked"
endif
if @Split2 == "Travel Deals-monthly" then
SET @acts1= "checked"
endif
if @Split2 == "Ski Deals Seasonal" then
SET @acts2= "checked"
endif
if @Split3 == "Seasonal travel information and trip ideas" then
SET @acts= "checked"
endif
if @Split3 == "Travel Deals-monthly" then
SET @acts1= "checked"
endif
if @Split3 == "Ski Deals Seasonal" then
SET @acts2= "checked"
endif
endif
/*</div>*/
]%%
<br>%%=v(@Split1)=%%
<br>%%=v(@Split2)=%%
<br>%%=v(@Split3)=%%
<form id="myForm" method="post" action="http://pages.S7.exacttarget.com/page.aspx?QS=38dfbe491fab00ea0ad4b925273e8608d40bab6a35b96d3428a16f6a0f519dc7">
<br>Email: <input type="text" name="test4" value="%%=v(@email)=%%" />
<br>Checkbox:<input type="checkbox" name="test5" value="Seasonal travel information and trip ideas" %%=v(@acts)=%%/> Seasonal travel information and trip ideas
<br><input type="checkbox" name="test5" value="Travel Deals-monthly" %%=v(@acts1)=%%/> Travel Deals-monthly
<br><input type="checkbox" name="test5" value="Ski Deals Seasonal" %%=v(@acts2)=%%/> Ski Deals Seasonal
<br><input type="submit" value="submit"/>
</form>
Here I am using lot of If conditions in these lines:
if @Split1 == "Seasonal travel information and trip ideas" then
SET @acts= "checked"
endif
if @Split1 == "Travel Deals-monthly" then
SET @acts1= "checked"
endif
if @Split1 == "Ski Deals Seasonal" then
SET@acts2 = "checked"
endif
if @Split2 == "Seasonal travel information and trip ideas" then
SET @acts= "checked"
endif
if @Split2 == "Travel Deals-monthly" then
SET @acts1= "checked"
endif
if @Split2 == "Ski Deals Seasonal" then
SET @acts2= "checked"
endif
if @Split3 == "Seasonal travel information and trip ideas" then
SET @acts= "checked"
endif
if @Split3 == "Travel Deals-monthly" then
SET @acts1= "checked"
endif
if @Split3 == "Ski Deals Seasonal" then
SET @acts2= "checked"
endif
Is it possible to minimize the If conditions using AMPScript code? can anyone please help me?