When creating a quote (in draft mode, not published), I’d like to use the line items in the quote to calculate the maximum “end date” across the line items and insert this value in the comments section. So for example, say there is 1 line item. Billing start date is 9/1/2025 with a term of 12 months. I want to have a sentence in the comments section that says “This contract ends on 9/1/2026”. Or if there are more line items, use the latest end date taking into account each line item’s start and term.
My research initially said to use a HubL macro to generate that sentence. Presumably by looping over the line items. But I was told HubL doesn’t know how to do exact date calculations (i.e. taking into account leap years, different month days, etc.). Using javascript also not an option cause we need the PDF download to be consistent with the published web output.
I also went down the rabbit hole of using workflows. I created a custom quote property (end_date), and used a workflow trigger on last modified for draft status quotes to update the end_date property as the user set up their line items. I came to find that the quote property does actually get updated, but the quote editor no longer uses any values from the quote object once it opens. It caches the quote poperties at open and any “behind the scene” updates to the quote object are not seen. Even worse, even if you ignore the lack of preview update and still hope that publishing the quote would use the live quote object values you’d be wrong. It uses it’s cached copy of the quote object properties to generate the actual quote!
I even thought that I have to tell the users to close the editor and reopen it right before clicking publish. But the editor still somehow uses it’s cached copy and doesn’t update to the db values of the object (which I verify to be updated correctly via an API get call).
So, what are my options? How can I simply show this end date value in my comment section?