Please find the below script which is not working whereas the code seems proper
{% let age1=0 %}
{% let datedifference = dateDiff(toDateTimeOnly(currentTimeInMillis()), toDateTimeOnly(profile.person.birthDate))%}
{% let age1 = absolute(toInt(roundUp(datedifference/365)))%}
{%#if age1=20.0 or age1=30.0 or age1=40.0 or age1=50.0 %} {
"content_id": "content1",
"param1": "{%= titleCase(profile.person.name.firstName)%}",
"param2": "{{age1}}"
}
{%else %} {
"content_id": "content2",
"param1": "{{age1}}"
} {%/if%}
Solved! Go to Solution.
Views
Replies
Total Likes
When one of absolute and toInt functions are applied, you would have only the integer or the absolute value.
following if part won't be satisfied and it would always return the else part.
{%#if age1=20.0 or age1=30.0 or age1=40.0 or age1=50.0 %}
Also, there is a native age function https://experienceleague.adobe.com/en/docs/journey-optimizer/using/content-management/personalizatio... which can be used in your case there by simplifying your checks even further
@gengaipandi11 are you getting any error? can you please share more details around "Not working"?
Views
Replies
Total Likes
Not throwing any error, but it is not showing any result as well as it is blocking all other offers in the system where adobe support team mentioned toInt function is causing issue. But, it is the function available for us to use. Do you see any other error in this code
Views
Replies
Total Likes
Hi @gengaipandi11 ,
Few observations :-
In the dateDiff function, the first parameter is in milliseconds. Why is the first parameter in milliseconds while the second is in DateTime format? Will this provide the difference in days?
When comparing date differences, you should consider using the now() function to make the logic more robust for the next line of code.
Additionally, when comparing age, ensure you use the correct comparison operator. The statement age1=20.0 assigns a value instead of comparing. Please check the use of the == operator for comparison.
Lastly, cross-verify the syntax of your conditional statements.
Thanks,
Somen
Views
Replies
Total Likes
When one of absolute and toInt functions are applied, you would have only the integer or the absolute value.
following if part won't be satisfied and it would always return the else part.
{%#if age1=20.0 or age1=30.0 or age1=40.0 or age1=50.0 %}
Also, there is a native age function https://experienceleague.adobe.com/en/docs/journey-optimizer/using/content-management/personalizatio... which can be used in your case there by simplifying your checks even further
yes, it is working now. but one thing is toInt is not working as expected. it was blocking whole offers. do you have any idea why?
Views
Replies
Total Likes