I need to sort an asset listing by the total of two metadata values. They’re accommodation contract options, and each asset has a metadata value for room rate and another for meal package rate (text fields). Originally, the total only needed to be printed on the front end, so I’ve use the following keyword replacement in the type format to display the total on the front end: %asset_metadata_Room_rate^add:{asset_metadata_Meal_rate^number_format:2%
I now have an additional requirement to sort a listing by this total, but the total doesn’t actually exist as an asset attribute. I’ve added a “total” metadata field and attempted to automatically populate this with the keyword replacements in a few different formats as the default value, but that doesn’t seem to work. Is there an easy way to do this, without my having to manually populate this new field with the calculated value?
I’ve not done this before myself - but have you tried sorting by “asset keyword value” - then dropping your keyword in there?
You’d have to remember to have the default sorting set to “presentation value” and not RAW.
Not sure what the performance hit would be for doing it that way.
What default keywords have you tried?
The other option is to use triggers to set the total metadata value when the other fields are updated (you’d need to replace keywords and ‘fix’ the value so it’s not in keyword format in the metadata.)
Thanks @PeterM - I did try that, but it’s not calculating. The third field only picks up the first value, and doesn’t add the second. I have found a workaround, though, by cascading, as the second value is quite uniform.