Search an array in expression | Community
Skip to main content
Level 3
July 10, 2023
Solved

Search an array in expression

  • July 10, 2023
  • 1 reply
  • 1891 views

Hi,

 

I want to check if a certain word is in the article name of an order, so I use the contain function. That works, only how do I check every position of the array? Because now it only checks position 0 as you see at the at(0). I want to check every position of the array, how can I do that in combination with this expression:


containIgnoreCase(@{ord_paid._company.igOrder.igEntries.at(0).igArticleName.igArticleNameNL}, "geldterug")
or containIgnoreCase(@{ord_paid._company.igOrder.igEntries.at(0).igArticleName.igArticleNameNL}, "aanbetaling")

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 Mohan_Dugganab

We are running into this issue again, can someone help us here? 


Kindly refer to the collection management functions detailed in this documentation https://experienceleague.adobe.com/docs/journey-optimizer/using/orchestrate-journeys/building-advanced-conditions-journeys/syntax/collection-management-functions.html?lang=en

1 reply

akshaaga
Adobe Employee
Adobe Employee
July 15, 2023

@talithapa ,

If you want to match arbitrary words, you have to programatically construct a RegExp (regular expression) object itself based on the word string and use test.

But, if you want to just find the characters, then you can use indexOf.

TalithaPaAuthor
Level 3
July 18, 2023

Hi,

Thanks for your reply and that you are willing to help me.

 

I don't think you totally understand me. If I use the Regexp, it still only searches at position 0.

Let me explain it again.

 

The contextual attribute for the article name is an array because you can order multiple products. I want to send everyone an e-mail with who has an article name that has the word 'geldterugbon' in it. 

When a field is not an array, I can do that like this: 

containIgnoreCase(@{ord_paid._company.igOrder.igEntries.igArticleName.igArticleNameNL}, "geldterug")

BUT, since the field IS an array, the expression looks like this: 

containIgnoreCase(@{ord_paid._company.igOrder.igEntries.at(0).igArticleName.igArticleNameNL}, "geldterug")

 

The bold part means that it only checks the articlename at position 0, so it only checks the first article you ordered. But also if the article is the 4th article in one purhcase, I want to send the e-mail. 

So I don't only want to check at position 0, but at every position. 

 

I can not simply remove the .at(0), that doesn't work because it is an array. 

 

This issue is quite similar and there the answer is to use the every function, but I don't think it works in this case. At least I have no idea how: https://experienceleaguecommunities.adobe.com/t5/journey-optimizer-questions/search-array-in-expression/m-p/567035#M230 

 

Hope someone can help since this is not very clearly stated in the documentation. 

 

@akshaaga maybe you can help? 

Sukrity_Wadhwa
Community Manager
Community Manager
July 24, 2023

Hi @akshaaga,

Could you please help @talithapa further here?

Thanks!

Sukrity Wadhwa