1

I am trying to conditionally display rows in a table. However it seems like the once the code reaches a record where the condition "IF IndexOf(@ClientContent, @MPEContent) > 0 AND IndexOf(@ClientLanguage,@MPELanguage) > 0" is no longer met it stops.

I'm guessing I have this condition in the wrong place within the code:

%%[ 
 var @IndexEquity, @OverUnderweightEquity, @PositioningEquity, @AllRecordsEquity, @RowCountEquity, @MPEContent, @MPELanguage
 set @AllRecordsEquity = LookupOrderedRows("Weekly Indices", 2000, "Sort_Order__c Asc", "Content_Block__c", "Managed Portfolios", "Index_Category__c", "Equity")
 set @RowCountEquity = rowcount(@AllRecordsEquity)
 SET @ClientContent = [Newsletter_Content__c]
 SET @ClientLanguage = [Newsletter_Language__c]
]%%

<table id="stocks" cellpadding="6" cellspacing="0" width="100%" style="border: 1px;" rules="none">
 <tr bgcolor="#dddddd">
    <th width="35%" style="border-bottom:1px solid #00008B;">Stocks (Equities)</th>
    <th width="10%" style="border-bottom:1px solid #00008B;"></th>
    <th width="55%" style="border-bottom:1px solid #00008B;">Rationale</th>
  </tr>


    %%[     
    IF @RowCountEquity > 0 THEN
      FOR @i = 1 TO @RowCountEquity DO
        set @IndexEquity = Field(Row(@AllRecordsEquity,@i),"Name")
        set @OverUnderweightEquity = Field(Row(@AllRecordsEquity,@i),"OverUnderWeight__c")
        set @PositioningEquity = Field(Row(@AllRecordsEquity,@i),"Managed_Portfolio_Positionning__c")
        set @MPEContent = Field(Row(@AllRecordsEquity,@i),"Content__c")
        set @MPELanguage = Field(Row(@AllRecordsEquity,@i),"Language__c")

    IF IndexOf(@ClientContent, @MPEContent) > 0  AND IndexOf(@ClientLanguage,@MPELanguage) > 0 THEN

    ]%% 

    <tr>  
        <td style="border-bottom:1px solid #00008B;"> %%=v(@IndexEquity)=%% </td>
        <td style="border-bottom:1px solid #00008B;"> </td>             
        <td style="border-bottom:1px solid #00008B;"> %%=v(@PositioningEquity)=%% </td>
    </tr>

%%[
    ENDIF
        NEXT @i
    ELSE
        No Rows Found
    ENDIF
]%%

</table>

 

1 Answer 1

0

I think the "stop" you're experiencing is due to a missing condition handler⁠—a second "No Rows Found" ELSE statement to handle the inner MPEContent/MPELanguage conditional (the existing ELSE statement only handles the outer RowCount conditional).

You could try something like...

/* code above truncated for brevity */  
    IF IndexOf(@ClientContent, @MPEContent) > 0 AND IndexOf(@ClientLanguage,@MPELanguage) > 0 THEN
]%%
  <tr>  
    <td style="border-bottom:1px solid #00008B;">%%=v(@IndexEquity)=%%</td>
    <td style="border-bottom:1px solid #00008B;"></td>             
    <td style="border-bottom:1px solid #00008B;">%%=v(@PositioningEquity)=%%</td>
  </tr>
%%[
    ELSE
]%%
  <tr>
    <td style="border-bottom:1px solid #00008B;" colspan="3">MPEContent/MPELanguage Not Found</td>
  </tr>
%%[
    ENDIF
  NEXT @i
ELSE
]%%
  <tr>
    <td style="border-bottom:1px solid #00008B;" colspan="3">No Rows Found</td>
  </tr>
%%[
ENDIF
]%%

Or another approach that waits until the loop is complete... add the following line ABOVE the FOR loop (e.g., at the top somewhere): set @MPECounter = 0

/* code above truncated for brevity */      
    IF IndexOf(@ClientContent, @MPEContent) > 0 AND IndexOf(@ClientLanguage,@MPELanguage) > 0 THEN
      set @MPECounter = Add(@MPECounter, 1)
]%%
  <tr>  
    <td style="border-bottom:1px solid #00008B;">%%=v(@IndexEquity)=%%</td>
    <td style="border-bottom:1px solid #00008B;"></td>             
    <td style="border-bottom:1px solid #00008B;">%%=v(@PositioningEquity)=%%</td>
  </tr>
%%[
    ENDIF
  NEXT @i
  IF (@MPECounter < 1) THEN /* MPEContent/MPELanguage criteria was never met */
]%%
  <tr>
    <td style="border-bottom:1px solid #00008B;" colspan="3">No Rows Found</td>
  </tr>
%%[
  ENDIF
ELSE
]%%
  <tr>
    <td style="border-bottom:1px solid #00008B;" colspan="3">No Rows Found</td>
  </tr>
%%[
ENDIF
]%%

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .