Hi Joran,
I add the same requirement myself and i ended up writing a java action for this:
package utilmodule.actions;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;
public class ReduceListToString extends CustomJavaAction<java.lang.String>
{
private java.util.List<IMendixObject> listToReduce;
private java.lang.String entityMember;
private java.lang.String separator;
private java.lang.Boolean skipEmptyString;
public ReduceListToString(IContext context, java.util.List<IMendixObject> listToReduce, java.lang.String entityMember, java.lang.String separator, java.lang.Boolean skipEmptyString)
{
super(context);
this.listToReduce = listToReduce;
this.entityMember = entityMember;
this.separator = separator;
this.skipEmptyString = skipEmptyString;
}
@Override
public java.lang.String executeAction() throws Exception
{
// BEGIN USER CODE
IContext context = getContext();
if (this.listToReduce.isEmpty()
|| !this.listToReduce.get(0).hasMember(entityMember)) {
return "";
}
else {
Stream<String> stream = this.listToReduce.stream().
map((e) -> e.getMember(context, this.entityMember).parseValueToString(context));
if (skipEmptyString) {
return stream.
filter((s) -> s!=null && s.trim().length()>0).
collect(Collectors.joining(this.separator));
}
else {
return stream.collect(Collectors.joining(this.separator));
}
}
// END USER CODE
}
/**
* Returns a string representation of this action
*/
@Override
public java.lang.String toString()
{
return "ReduceListToString";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}
Hope this can help you.
Regards