I'm having an issue trying to combine multiple rows into an email. As an example, I want to take the below data (Policy Data) and combine data where the policy number is the same and display that information within a table in an email. Like the below...
Policy Number|First Name|Relationship
1111 |Steve |Primary
1111 |Mary |Spouse
1111 |Dave |Child
1111 |Wendy |Child
I've pasted below as well my AMPscript.
Policy_data
Policy_Number|First_Name|Relationship
1111|Steve|Primary
1111|Mary|Spouse
1111|Dave|Child
1111|Wendy|Child
2222|Morgan|Primary
2222|Tom|Child
3333|Greg|Primary
4444|Kayla|Primary
<html>
…
Hi, your policy has the following members:
<table>
%%[
set @rows = LookupRows(Policy_Data,Policy_Number,Policy_Number)
set @rc = RowCount(@rows)
for @i = 1 TO @rc DO
set @row = Row(@rows, @i)
set @fName = Field(@row, first_name)
set @relationship = Field(@row, relationship)
]%%
<tr><td>%%=v(@fName)=%%</td><td>%%=v(@relationship)=%%</td></tr>
%%[next @r]%%
%%[end]%%
</table>
</html>
Wondering if anyone has had any similar experience?
Thanks!
salesforce
combine data where the policy number is the same and display that information within a table in an email
? If you mean just looping through the whole thing, you are fairly close with what you have. And to that extent, what error or unexpected output are you getting from current code?