BUG? Can't add "IF" string comparison to System Default Page

I’m trying to customize the System Page > Default Page, but keep getting the “Liquid Error: Object reference not set to an instance of an object.” error.

In trying to debug, here’s what I’ve uncovered. If I compare strings it fails. If I compare integers it works:

This works:
{% if 1 ==1 %}
{% else %}
{% endif %}

And this fails:
{% if “1” == “1” %}
{% else %}
{% endif %}

I’m trying to implement something like the following to redirect a user submitted custom module after using the input form:
{% if this.PageType == “AddNewModuleItemSuccess” %}
{% if this.FormSubmissionData.ModuleItem.ParentId == “2437” %}
use js to redirect to item url
{% endif %}
{% else %}
< div>
< /div>
{% endif %}

Have you tried the ParentId as an integer? ie:

{% if this.FormSubmissionData.ModuleItem.ParentId == 2437 %}

I just did a test with your code and it worked fine for me (both ways, comparing the ParentID as a number or a string).

And tested with Liquid 2.0 on and off - both ways worked.

So must be something else going on here I think…

Usually that Liquid error relates to a component module with something wrong in it, not from conditional statements (in my experience).

Yes that works.

But …

  1. The parent id is off by 5, right?
  2. I really will need to the string comparisons for more complex logic

Have you tested any string? {% if this.PageType == “AddNewModuleItemSuccess” %}

  1. Yes, id is off by 5. You can double check you have it right by outputting the object, ie: ({{this.FormSubmissionData.ModuleItem.ParentId}})

Yes. Tested your exact code and both conditionals worked.

Check your double quotes in the first if statement. I think you have ‘smart quotes’ there instead of normal quotes.

I get the same error when I change these to smart quotes, eg:

smart quotes:


normal quotes:


Single quotes worked! Thanks!

Also … another roadblock. My redirect is failing:

This tag produces:

and I get a Page Not Found.

The url that works is:

Do I need to encode or decode it?

Yeah, looks like you need to encode it.


“| Url_encode” didn’t work. (“Url_decode” didn’t either).
How would it know which dashes were real and which aren’t?

I was able cobble it together with hard-coding the module path and the Url slug.

Don’t you think that this {{this.FormSubmissionData.ModuleItem.Url}} might be a bug. I mean, shouldn’t it produce a working Url?

Adam - Thanks so much for taking the time to help! I so appreciate it :slight_smile: :star_struck:

No problem @shannonlynd. Happy to help.

Yes, looks like the bug is to do with user submitted items not following the same URL convention as what is generated when adding items in the admin.
It keeps the spaces in the URL and so we need the %20 encoding for a space.
But the Liquid output in the form submission shows it with dashes.

Ideally, the user-submission process should convert spaces to dashes for consistency.

@vlad.z looks like this is a bug.

Added to the known bugs section of the team backlog