0

I have multiple fields that have multiple values per email address. I have a policy number field and that can have multiple policy numbers and then I have a price field that holds the price for each of those policy numbers. The prices and policies are delimited by the pipe.

[Policy_Number] value is 340575181|340575182 [Policy_Price] value is 0.00|0

My current code

%%[

Set @Policy_Number_Values = BuildRowsetFromString([Policy_Number],'|')

for @i = 1 to Rowcount(@Policy_Number_Values) do

    Set @row = Row(@Policy_Number_Values, @i)
    Set @policy = Field(@row,1)

    Set @Policy_Price_Values = BuildRowsetFromString([Policy_Price],"|")
    Set @Policy_Name_SKU = BuildRowsetFromString([Policy_Name_SKU],"|")
    Set @Coverage_End_Date = BuildRowsetFromString([Coverage_End_Date],"|")

    for @j = 1 to Rowcount(@Policy_Price_Values) do

        Set @rowj = Row(@Policy_Price_Values, @j)
        Set @price = Field(@rowj,1)

    ]%%   

        Your contract number: %%Policy_Number%% or Policy: %%=v(@policy)=%%
        Your purchase: %%=v(@Policy_Name_SKU)=%%
        Total price of plan: $%%Policy_Price%% or Price: $%%=v(@Price)=%% 
        Deductible amount: $0.00 
        Coverage start date*: %%Coverage_Start_Date%% 
        Coverage end date: %%=v(@Coverage_End_Date)=%% 

    %%[ next @j ]%%

%%[ next @i ]%%

However it outputs 4 instances (two for next @j and two for next @i) and I only want to display 2.

My current output is:

Your contract number: 340575181
Your purchase:
Total price of plan: $0.00
Deductible amount: $0.00
Coverage start date*: 8/13/2015
Coverage end date:

Your contract number: 340575181
Your purchase:
Total price of plan: $0
Deductible amount: $0.00
Coverage start date*: 8/13/2015
Coverage end date:

Your contract number: 340575182
Your purchase:
Total price of plan: $0.00
Deductible amount: $0.00
Coverage start date*: 8/13/2015
Coverage end date:

Your contract number: 340575182
Your purchase:
Total price of plan: $0
Deductible amount: $0.00
Coverage start date*: 8/13/2015
Coverage end date:

My desired output would be something like this:

Your contract number: 340575181
Your purchase:
Total price of plan: $0.00
Deductible amount: $0.00
Coverage start date*: 8/13/2015
Coverage end date:

Your contract number: 340575182
Your purchase:
Total price of plan: $0.00
Deductible amount: $0.00
Coverage start date*: 8/13/2015
Coverage end date:

Any suggestions on how to fix this?

  • Can you update your question with 1) a sample of the values in [Policy_Number] and [Policy_Price] and 2) an example of the desired output? – Adam Spriggs Aug 17 '15 at 13:34
  • Hi @Adam Springs, The value for [Policy_Number] is 340575181|340575182 and for [Policy_Price] is 0.00|0 I would like it to return something like this: Your contract number: 340575181|340575182 or Policy: 340575181 Your purchase: Total price of plan: $0.00|0 or Price: $0.00 Deductible amount: $0.00 Coverage start date*: 8/13/2015 Coverage end date: Your contract number: 340575181|340575182 or Policy: 340575181 Your purchase: Total price of plan: $0.00|0 or Price: $0 Deductible amount: $0.00 Coverage start date*: 8/13/2015 Coverage end date: – gcardona Aug 17 '15 at 14:38
  • You want to output the | characters? – Adam Spriggs Aug 17 '15 at 14:52
  • @Adam Springs: Something like this come out: Your contract number: 340575181 Your purchase: Total price of plan: $0.00 Deductible amount: $0.00 Coverage start date*: 8/13/2015 Coverage end date: Your contract number: 340575182 Your purchase: Total price of plan: $0.00 Deductible amount: $0.00 Coverage start date*: 8/13/2015 Coverage end date: I update the main post to show my current out. If you notice I get 4 instances/blocks of content of Contract Number and purchase price. I just want two. One for Policy # 340575181 and another for 340575182. – gcardona Aug 17 '15 at 14:59
1

You're not extracting the data from your rowsets in your inner loop. You'll need to do use the field() and row() functions on the SKUs and EndDates.

I also pulled the policy number out of the inner loop and added the output to the outer loop:

%%[

Set @Policy_Number_Values = BuildRowsetFromString([Policy_Number],'|')

for @i = 1 to Rowcount(@Policy_Number_Values) do

    Set @row = Row(@Policy_Number_Values, @i)
    Set @policy = Field(@row,1)

    ]%%
        <br><br>Your contract number: %%Policy_Number%% or Policy: %%=v(@policy)=%%
    %%[

    Set @Policy_Price_Values = BuildRowsetFromString([Policy_Price],"|")
    Set @Policy_Name_SKU = BuildRowsetFromString([Policy_Name_SKU],"|")
    Set @Coverage_End_Date = BuildRowsetFromString([Coverage_End_Date],"|")

    for @j = 1 to Rowcount(@Policy_Price_Values) do

        Set @prices = Row(@Policy_Price_Values, @j)
        Set @price = Field(@prices,1)

        set @skus =  Row(@Policy_Name_SKU, @j)
        set @sku =  Field(@skus,1)

        set @endDates = Row(@Coverage_End_Date, @j)
        set @endDate = Field(@endDates,1)

    ]%%   
        <br>Your purchase: %%=v(@sku)=%% 
        <br>Total price of plan: $%%Policy_Price%% or Price: $%%=v(@price)=%% 
        <br>Deductible amount: $0.00 
        <br>Coverage start date*: %%Coverage_Start_Date%% 
        <br>Coverage end date: %%=v(@endDate)=%%

    %%[ next @j ]%%

%%[ next @i ]%%
| improve this answer | |
  • Thank you so much for your help! This did what I needed. – gcardona Aug 17 '15 at 16:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.