Hi Fjordi,
So you have several instalment objects and need to combine all these values as concatenated strings in a new object. If all the values for an attribute are the same you only want to display that one value, if they are not all the same, you want to show the list of all values.
Without being able to iterate over attributes of an entity, this is not going to be a nice solution, I'm afraid.
I would create a (non-persistable) helper entity that, for each attribute, stores two values: the 'value' as string and a boolean to indicate whether all values for that attribute so far have been the same.
On your first iteration, fill the helper object values with the values from the first instalment. Make sure all the booleans are true (do this by setting the default value in the domain model).
On subsequent iterations, check the value of the instalment against the stored value in the helper object and set the attribute boolean of the helperobject to:
if ($instalment/attribute = $helper/attributevalue) then
$helper/attributeboolean
else
false
After processing all instalments, use the helper object to set the final value:
if ($helper/attributeboolean) then
$helper/attributevalue
else
$newobject/attributevalue