Skip to main content
Level 3
Mar 16, 2023 3:09 PM UTC
Solved

How does the contain function work?

Hi,

 

I want to check if the word 'POST' comes back in a contextual attribute: {{context.journey.events.00000._company.igOrder.igEntries.CarrierUid}}

 

So I want this:

 

If {{context.journey.events.00000._company.igOrder.igEntries.CarrierUid}} contains the word 'Post' ( not case sensitive), I want to show: "Post bezorging" in the e-mail.

 

I know how to use the if statements, but the documentation is totally not clear about how to use the contain function. 

 

Can someone help me with this?

 

Thanks!!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
TalithaPaAccepted solution
Level 3
Mar 29, 2023 2:58 PM UTC

Hi,

 

Thanks for all your help!

It turned out that the field was an array, so I have to use the each function first. Did that and then it worked 🙂 

 

@_manoj_kumar_ 

9 replies

Manoj_Kumar
Community Advisor
Community Advisor
Mar 17, 2023 1:41 AM UTC

Hello @talithapa 

 

You can do it like this.

 

{%#if(contains(context.journey.events.00000._company.igOrder.igEntries.CarrierUid, "post", false)) %} If field containss post print something {% else %} Post not found in the field {%/if%}

 

More info on function is available here: String functions library | Adobe Journey Optimizer

 

Translate
Manoj  | https://themartech.pro
TalithaPaAuthor
Level 3
Mar 22, 2023 9:30 AM UTC

Thanks @_manoj_kumar_  I am going to try this! 

Translate
adobechat
Level 5
Mar 28, 2023 3:43 PM UTC

Maybe try this? single quotes and little change in format.

if contains({{context.journey.events.00000._company.igOrder.igEntries.CarrierUid}}, 'Post') {
  // email
}

 

Translate
TalithaPaAuthorAccepted solution
Level 3
Mar 29, 2023 2:58 PM UTC

Hi,

 

Thanks for all your help!

It turned out that the field was an array, so I have to use the each function first. Did that and then it worked 🙂 

 

@_manoj_kumar_ 

Translate
Manoj_Kumar
Community Advisor
Community Advisor
Mar 30, 2023 12:46 AM UTC

Hello @talithapa, If possible, could you please share the code?

 

It does not work for me.

 

Translate
Manoj  | https://themartech.pro