Skip to main content
Solved

Null converted into nil

  • 26 April 2023
  • 1 reply
  • 53 views

Hello! 

 

I have created a campaign that triggers based on an event. In this campaign, I consume information from an endpoint, and using the response, I perform an extra request to retrieve the final data. With that final data I componse the email that is sent to our customers.

 

Since a month ago, I’ve noticed that there are errors happening in this process. It looks like when the first response comes, some of the fields can be null, and when I try to map the process seems to fail. My map looks like this:

{{customer.alternatives_based_on_last_listing_visited | map: 'ru_id' | join: ','}}

Even though my API returns null, when Liquid iterates over that attribute (alternatives_based_on_last_listing_visited), it has replaced all the null values with nil, which makes the map fail, and the result of that transformation is the string ru_id, rather than something like 1,2,3,4.

 

Have you faced something similar to this in the past? Any workaround? I cannot modify our API at the moment

Best answer by Ryan_cio

Hi there,

I tested this out on my end, with your Liquid code and this rendered the array by skipping the null values:

As you can see the null values were skipped, but the map worked and I was able to render the Liquid. I did run into a similar problem that you reported while testing, but I found found that my array wasn’t properly formatted. Could you check that the array is stored correctly as an attribute with no extra characters?

Thanks,

View original
Did this topic help you find an answer to your question?

1 reply

Ryan_cio
  • 49 replies
  • Answer
  • April 27, 2023

Hi there,

I tested this out on my end, with your Liquid code and this rendered the array by skipping the null values:

As you can see the null values were skipped, but the map worked and I was able to render the Liquid. I did run into a similar problem that you reported while testing, but I found found that my array wasn’t properly formatted. Could you check that the array is stored correctly as an attribute with no extra characters?

Thanks,


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings