Expand my Community achievements bar.

Join Adobe Journey Optimizer product experts for a live Ask Me Anything on June 25th at 8 AM PT!
SOLVED

Calculate a string field in one of Custom Actions variable fields

Avatar

Level 2
Level 2

Hi,

 

I'm not a developer and I'm trying to write an expression to count the number of a string field nested within string arrays (screenshot). This expression is intended for use in one of the Custom Actions variable fields in Journey. Below is the expression I attempted, along with the error I received: "The expression is invalid : Unexpected usage of the character '('. It seems that you should better use the '}' here."

 

Expression in question:

listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3 [].ObjectLevel4 [].each(currentDataPackField.plan)}

 

Kindly take note that there can be more than 1 ObjectLevel4 hence more than 1 plan.

Thanks!

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 2
Level 2

Hi @Mohan_Dugganab, very close:

 

Error: The expression is invalid : Unexpected character ')'. It seems that you are missing something before this

 

listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3.all(currentDataPackField.PathTofieldWithinObjectLevel3 !=).pathToObjectLevel4.all(currentDataPackField.PathTofieldWithinObjectLevel4.all())})

 

If I replace " != " with ".all()" in red, error is "The expression is invalid : Data pack field not found. It may have been deleted or you don't have permission to use it."

listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3.all(currentDataPackField.PathTofieldWithinObjectLevel3.all()).pathToObjectLevel4.all(currentDataPackField.PathTofieldWithinObjectLevel4.all())})

View solution in original post

11 Replies

Avatar

Level 4

Hello @AK5 ,


listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3 [].ObjectLevel4 [].each(currentDataPackField.plan)}).
at the end of expression,  i can see that you missed closing bracket ")".
Can you try this expression:
listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3[].ObjectLevel4[].currentDataPackField.plan})

Thanks

AJODev

Avatar

Level 2
Level 2

Hi @AJODev,

 

Thanks for looking into this! I'm getting a new error msg: "The expression is invalid : You cannot use the word 'currentDataPackField' like this because it is a keyword of the language. Please, add quotes to fix your expression."

 

Any idea?

 

Thanks!

Avatar

Level 4

@AK5 
Thanks for sharing with error message .try this expression
listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3[].ObjectLevel4[]['currentDataPackField'].plan})

Thanks

AJODev

Avatar

Level 2
Level 2

Hi @AJODev,

Almost there I reckon, it now says: "The expression is invalid : You cannot use the character '[' like this because it is a keyword of the language. Please, add quotes to fix your expression."

Thanks!

Avatar

Level 4

can you try adding double quotes to keyword "currentDataPackField" in your expression.

Avatar

Level 2
Level 2

 

Unexpected usage of the word '"currentDataPackField"'. It seems that you should better use the '}' here.

 

Other attempts:

1) {'currentDataPackField'}.plan}) > Unexpected usage of the character '{'. It seems that you should better use the '}' here.

2) ("currentDataPackField").plan}) > Unexpected usage of the character '('. It seems that you should better use the '}' here.

 

Thanks!

Avatar

Employee Advisor

You can validate it on the following lines 

listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3.all(currentDataPackField.PathTofieldWithinObjectLevel3 == '<filter value>').
pathToObjectLevel4.all(currentDataPackField.PathTofieldWithinObjectLevel4 == '<filter value>')}

Avatar

Level 2
Level 2

Hi @Mohan_Dugganab, given i'm looking to count the number of plan(s) that's a string, and the string field is hidden in an array that's also in an array of a few more arrays (as per screenshot), what do you suggest I replace  == '<filter value>' with?

 

Thanks!

Avatar

Employee Advisor

You can either put a condition like .....pathToPlanId != '' or remove the filter if you want to count all of them in ObjectLevel4 array object by specifying ...pathToObjectLevel4.all()}

Avatar

Correct answer by
Level 2
Level 2

Hi @Mohan_Dugganab, very close:

 

Error: The expression is invalid : Unexpected character ')'. It seems that you are missing something before this

 

listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3.all(currentDataPackField.PathTofieldWithinObjectLevel3 !=).pathToObjectLevel4.all(currentDataPackField.PathTofieldWithinObjectLevel4.all())})

 

If I replace " != " with ".all()" in red, error is "The expression is invalid : Data pack field not found. It may have been deleted or you don't have permission to use it."

listSize(#{ExperiencePlatform.ProfileFieldGroup.profile._ObjectLevel1.ObjectLevel2.ObjectLevel3.all(currentDataPackField.PathTofieldWithinObjectLevel3.all()).pathToObjectLevel4.all(currentDataPackField.PathTofieldWithinObjectLevel4.all())})

Avatar

Level 2
Level 2

Thanks @Mohan_Dugganab. I believe that should be right as I am not getting validation error rather, I'm getting the permission issue.