Expand my Community achievements bar.

Dive in, experiment, and see how our AI Assistant Content Accelerator can transform your workflows with personalized, efficient content solutions through our newly designed playground experience.
SOLVED

Comparison operator throwing error in fragment

Avatar

Level 2

I am using '>' operator to compare two dates in an AJO fragment as below.

{%#if coverage.coverageStartDate > currentTimeInMillis() %}

Although this doesn't give any error in validation, when I switch to the test mode of the journey which has an email using this fragment, it is throwing error as below.

\"The field expression of the Fragment Variant is malformed\",\"status\":422,\"report\":{\"tenantInfo\":{\"sandboxName\":\"aep\",\"sandboxId\":\"a0791891-d4d1-430d-b918-91d4d1a30d9b\",\"imsOrgId\":\"D845731D5B30B6010A495E2E@AdobeOrg\"},\"additionalContext\":{\"variantId\":\"6ef2261b-c9cb-4b1e-9986-02e24873a154\",\"line\":\"1\",\"fieldName\":\"expression\",\"column\":\"76\",\"name\":\"default\",\"title\":\"Invalid syntax Error in parsing PQL expression \\\"coverage.coverageStartDate > currentTimeInMillis()\\\": line 1:27 token recognition error at: '&'\",\"status\":\"422\"}}}]}"}}}]}}

 

Also, when I directly keep this code in the email template(personalization using expression editor) rather than using it through fragment it is working fine. Any idea on why this operator not working in fragment (of expression type) ?

Note: I checked the comparison using = operator in fragment. In this case it is not having an issue, but when I use < or > it is throwing error.

 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

@ngd_11 ,

 

The error you're encountering when using the > operator to compare two dates in a fragment likely arises from how expressions are handled within fragments in the context of date comparisons.

 

In fragments, especially when working with date fields, expressions might not behave the same way as they do in email templates when using the personalization expression editor. This could be due to variations in how expressions are parsed and evaluated within fragments.

To work around this issue, you can try using the gt function for date comparisons instead of the > operator.

Here's how you can rewrite your condition in the fragment:

{%#if gt(coverage.coverageStartDate, currentTimeInMillis()) %}

By using the gt function, you explicitly tell the platform to check if coverage.coverageStartDate is greater than currentTimeInMillis().

View solution in original post

2 Replies

Avatar

Correct answer by
Employee Advisor

@ngd_11 ,

 

The error you're encountering when using the > operator to compare two dates in a fragment likely arises from how expressions are handled within fragments in the context of date comparisons.

 

In fragments, especially when working with date fields, expressions might not behave the same way as they do in email templates when using the personalization expression editor. This could be due to variations in how expressions are parsed and evaluated within fragments.

To work around this issue, you can try using the gt function for date comparisons instead of the > operator.

Here's how you can rewrite your condition in the fragment:

{%#if gt(coverage.coverageStartDate, currentTimeInMillis()) %}

By using the gt function, you explicitly tell the platform to check if coverage.coverageStartDate is greater than currentTimeInMillis().