How does the contain function work? | Community
Skip to main content
New Participant
March 16, 2023
Solved

How does the contain function work?

  • March 16, 2023
  • 2 replies
  • 2588 views

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.
Best answer by TalithaPa

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_ 

2 replies

adobechat
New Participant
March 28, 2023

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

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

 

TalithaPaAuthorAccepted solution
New Participant
March 29, 2023

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_ 

_Manoj_Kumar_
New Participant
March 30, 2023

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

 

It does not work for me.

 

     Manoj     Find me on LinkedIn
_Manoj_Kumar_
New Participant
March 17, 2023

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

 

     Manoj     Find me on LinkedIn
TalithaPaAuthor
New Participant
March 22, 2023

Thanks @_manoj_kumar_  I am going to try this!