How to use $currentCustomfieldValue variable with multiple values



Setting a Display view for Elements Connect field is optional; however, it might make big difference especially for the performance. We won't get into the details above as it's all explained in the Display View Configuration page.

In the Display View, we access the field Key through the $currentCustomfieldValue Velocity variable. 

Suppose we have a user picker Elements Connect field, Live Text type.

Edit Query:

select id, user_name , display_name , email_address
from cwd_user

If the user was allowed to select single value in the Edit view, setting the Display View will be easy and direct by using the $currentCustomfieldValue variable.



Display query for Single value selection



If the user was allowed to select multiple values in the Edit view, setting the Display View will be by using the $currentCustomfieldValue variable and a function that will handle the multiple values; otherwise, only the first value will be displayed.

The below screenshot, demonstrates an Elements Connect field with multiple value selection. Therefore, to access the field Key in the Display query, we need to use the $currentCustomfieldValue variable with of the function intList(), stringList(), or serialize(<string>). All details about these functions could be found in our documentation.



Edit Query for a select list




Case 1: The Key stores multi integer values

If the Key was set on the id (integer number), the display query will looks like:

select id, user_name , display_name , email_address
from cwd_user
where id in ($currentCustomfieldValue.intList())

This is an example of the field Display View configuration.



DisplayView Multiple Values Integer Key




Case 2: The Key stores multi strings (characters) values

If the Key was set on the user_name (characters), the display query will looks like:

select id, user_name , display_name , email_address
from cwd_user
where user_name in ($currentCustomfieldValue.stringList())

This is an example of the field Display View configuration in this case.



Multiple Values Display Query Character Key