Question

Photo of Andrew Metz

0

Set an item attribute with lava

I'm looking to add an attribute "EndDate" to my sermon series entry. I'd like to use lava to automatically set this day from the most recent child's (message item) start date. Any thoughts on how I could do this? Can you use Lava to set an attribute value?

  • Photo of David Stevens

    0

    You have a couple options, although your easiest way forward is most likely to dynamically calculate the EndDate wherever you're outputting the value.  If you have the child items, you'd use a for loop ( {% for item in items %} ) with an if statement ( {% if StartDate > variableMaxStartDate %} ) to capture the most recent start date.

    Lava by design is a functional programming language.  It's intended to receive a value, transform or modify it, then pass on the updated value.  The core team did add EXECUTE, SQL, and WEBREQUEST commands, so if you wanted to update the database with a new AttributeValue you would have to enable and use one of those special commands.