I am trying to build a dynamic From Name using amp script. In our business case customers can book multiple tours with various reservation agents; in this case we want to send a dynamic From Name as coming from the Reservation agent that they booked most with.
amp Script code in my emails is the following:
%%[var @BookerEmail, @ResAgent, @ProductName, @row,@rows,@rowCount SET @rows=LookupOrderedRows('Example_Past_Pax_Bozi',0,'Res Agent ASC','Contact ID',[Contact ID]) SET @rowCount=RowCount(@rows) if @rowCount>0 then]%% <table> <tr> <td>Res Agent</td> <td>Tour</td> <td>Tour count per res agent</td> </tr>%%[ for @i=1 to RowCount(@rows) do SET @row=ROW(@rows,@i)]%% <tr> <td>%%=field(@row,"Res Agent")=%%</td> <td>%%=field(@row,"Product Name")=%%</td> <td>%%=RowCount(LookupRows('Example_Past_Pax_Bozi','Res Agent',field(@row,"Res Agent")))=%%</td> </tr>%%[Next @i]%% </table>%%[else]%% %%[endif]%%
I am also attaching a print screen when we do preview.
I am not sure how I can incorporate the RowCount into building a variable that i can then use in the Sender Profile.
I have tried doing the count via SQL and add it into a new data extension but it feels like circling back and forth.