Skip to main content

I’m working on creating an order cancellation email based on event data from our OMS. The current event data I’m working with has a product array of all items in the order, with each item having a status of shipped, cancelled, etc. 

I have my template setup and correctly pulling the items from the event, however it is pulling all items in the event rather than just the “cancelled” ones.

When using a dynamic table, is it possible to add filtering logic in the row collection field that would only loop through products that evaluate “true” for a specific attribute?

 

 

Hello @bmask,

Good question!

Currently, it would not be possible to add filtering logic to the Row Collection field when building out a dynamic Table Block using Klaviyo's drag-and-drop editor. You can, however, use conditional logic, or "if/else" statements, to the Source of a dynamic Table Block to show/hide content based on your custom conditions.

The Row Collection and Row Alias, which allows you to loop over functions, is essentially a simplified "for" loop. This means if you wish to build in addition logic to your dynamic block, such as filtering by items that are/are not marked as "cancelled", you can do so by using a "if" statement by checking whether the value in your event data is/is not equal to "cancelled". I mentioned this in a similar Community post which I’ve included below:

I would also suggest reviewing the following Help Center articles as they may prove helpful in further understanding how a dynamic table block functions and built out:

 

I hope this helps!

David


@David To Thanks for the guidance here. I added the following if/else logic to the table source which is now correctly hiding items not “cancelled” however now I’m left with a big empty space. Am I doing something wrong or is there some way around this?

 

 

 


Hey @bmask,

Glad to hear your if/else statement logics work! This blank space seems to be appearing as you seem to be using a non traditional method of building your table block. Unlike the traditional method of building in a table block with just two columns while applying your logic you went with three columns while introducing the if/else logic to each one which seems to be just iterating through and “hiding” rather than skipping the omitted product. 

Instead you may want to revert to the traditional method to alleviate this issue of having a gap appear in your email by rebuilding your dynamic table block using two columns. @retention has a great write up on excluding products when using a dynamic table block in the Community post below which I believe could be useful in reviewing!

If you were still having troubles, it may be a good idea to reach out to an email designer or finding one from our accredited Klaviyo Partner Directory for more assistance!

David


I’m not sure I’m following. I’m using the standard Klaviyo table block. Why would two columns be any different than three columns?

In the article you reference, there is the ability to add source code at the dynamic row level. I know that was available in the old editor, but is it available in the new editor? In the screenshot below I show the options I’m seeing which are only to edit the individual column within a dynamic row.

 


Hey @bmask,

Although using three columns wouldn’t typically be an issue, using less columns when creating a dynamic block introduces less mistakes to the table block and the content you are trying to render for. 

From my understanding, when building a dynamic table block within our old editor or our new editor, neither options would allow you to adjust the source code at the dynamic row level. This is actually where the dynamic loop and/or block repeat feature come in which allow you to specific the variables you wish to loop over on a row level.

Assuming you were talking about the Repeating a Block Based on Dynamic Data Help Center article I provided earlier, the block repeat function would still be available in our new editor. This repeat function can be found in the new editor under the Display Options tab listed as CONTENT REPEAT. Keep in mind that if you happened to enable both the Dynamic aspect of a table block and the Repeat function, this will often times lead to an unexpected behavior of content repeating due how both settings are simplified implementations of a “for” loop. 

Since your setup is a bit more complicated and I don’t want to make further assumptions, I would advise reaching out to our Support Team who can take a closer look at the template for assistance as it may require viewing the template as whole to further troubleshoot. Alternatively, if you were having trouble coding your emails, it may be wise to find an email designer from our accredited Klaviyo Partner Directory who can provide more hands on assistance. 

David


Reply