0

I've checked all the topic regarding this issue but still cannot figure it out,

Here is the code:

%%[           

SET @promo = Attributevalue('Is_promotion')
SET @lookOrders = lookuprows("Recos_Nouveaux_produits_Algolia","Is_promotion",@promo)
SET @nbreco = rowcount(@lookOrders)

FOR @i = 7 TO 9 DO

    SET @row = row(@lookOrders, @i)
    SET @title = field(@row, 'title')
    SET @ean = field(@row, 'ean')
    SET @brand = field(@row, 'brand')
    SET @price = field(@row, 'price')
    SET @sellerName = field(@row, 'sellerName')
    SET @productCountRating = field(@row, 'productCountRating')
    SET @originalPrice = field(@row, 'originalPrice')
    SET @categoryName = field(@row, 'categoryName')
    SET @parentCategoryName = field(@row, 'parentCategoryName')
    SET @grandParentCategoryName = field(@row, 'grandParentCategoryName')
    SET @images_1 = field(@row, 'images_1')
    SET @images_2 = field(@row, 'images_2')
    SET @attributes_name_seo_fr = field(@row, 'attributes_name_seo_fr')
    SET @attributes_short_description_seo_fr = field(@row, 'attributes_short_description_seo_fr')
    SET @highlightResult_brand_value = field(@row, 'highlightResult_brand_value')
    SET @Product_url = field(@row, 'Product_url')            

]%%

%%[next @i]%%

The thing is that the field 'Is_promotion' is a boolean but whenever i pass to the preview & test step, i have the following error message, it's like not considering any "true" value :

Invalid index (parameter 2) passed to Row function. Index must be less than or equal to the row count. Index Value: 7 Row Count: 6 Function: row(@lookOrders, @i)

if anyone already faced this problem and can help, i'll be grateful. Thank's

1 Answer 1

1

Your code won't handle result sets of less than 7 rows. You'll need to check the number of rows returned before you loop.

%%[           

SET @promo = Attributevalue('Is_promotion')
SET @lookOrders = lookuprows("Recos_Nouveaux_produits_Algolia","Is_promotion",@promo)
SET @nbreco = rowcount(@lookOrders)

if @nbreco >= 7 and @nbreco <= 9 then 

    FOR @i = 7 TO 9 DO

        SET @row = row(@lookOrders, @i)

        SET @title = field(@row, 'title')
        SET @ean = field(@row, 'ean')
        SET @brand = field(@row, 'brand')
        SET @price = field(@row, 'price')
        SET @sellerName = field(@row, 'sellerName')
        SET @productCountRating = field(@row, 'productCountRating')
        SET @originalPrice = field(@row, 'originalPrice')
        SET @categoryName = field(@row, 'categoryName')
        SET @parentCategoryName = field(@row, 'parentCategoryName')
        SET @grandParentCategoryName = field(@row, 'grandParentCategoryName')
        SET @images_1 = field(@row, 'images_1')
        SET @images_2 = field(@row, 'images_2')
        SET @attributes_name_seo_fr = field(@row, 'attributes_name_seo_fr')
        SET @attributes_short_description_seo_fr = field(@row, 'attributes_short_description_seo_fr')
        SET @highlightResult_brand_value = field(@row, 'highlightResult_brand_value')
        SET @Product_url = field(@row, 'Product_url')            
    ]%%

    <br>title: %%=v(@title)=%%
    <br>ean: %%=v(@ean)=%%
    <br>brand: %%=v(@brand)=%%
    <br>price: %%=v(@price)=%%
    <br>sellerName: %%=v(@sellerName)=%%
    <br>productCountRating: %%=v(@productCountRating)=%%
    <br>originalPrice: %%=v(@originalPrice)=%%
    <br>categoryName: %%=v(@categoryName)=%%
    <br>parentCategoryName: %%=v(@parentCategoryName)=%%
    <br>grandParentCategoryName: %%=v(@grandParentCategoryName)=%%
    <br>images_1: %%=v(@images_1)=%%
    <br>images_2: %%=v(@images_2)=%%
    <br>attributes_name_seo_fr: %%=v(@attributes_name_seo_fr)=%%
    <br>attributes_short_description_seo_fr: %%=v(@attributes_short_description_seo_fr)=%%
    <br>highlightResult_brand_value: %%=v(@highlightResult_brand_value)=%%
    <br>Product_url: %%=v(@Product_url    )=%%

    %%[ next @i ]%%
    
%%[ endif ]%%

You must log in to answer this question.

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