Expand my Community achievements bar.

Join us for the Community Q&A Coffee Break on May 2nd at 8 am PT with Adobe Journey Optimizer experts Robert Calangiu, Brent Kostak & Sandra Hausmann.

Search an array in expression

Avatar

Level 3

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!

7 Replies

Avatar

Employee Advisor

@Taal ,

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.

Avatar

Level 3

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.

icostan2_0-1689681850091.png

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-express... 

 

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

 

@akshaaga maybe you can help? 

Avatar

Administrator

Hi @akshaaga,

Could you please help @Taal further here?

Thanks!



Sukrity Wadhwa

Avatar

Level 5

Hi, 

 

Was this resolved? I am running into the same issue.

 

Thanks,

Avatar

Level 3

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

Avatar

Administrator

Hi @Taal,

Was this documentation URL helpful to resolve your query or do you still need more help here? Do let us know.

Thanks!



Sukrity Wadhwa