Declare Expression property is blank in Report Definition but calculated correctly on UI in Constellation

Hi everyone,

I’m facing an issue in a Pega Constellation application and would appreciate any guidance.

Scenario:

  • I have a Leave Request case type.
  • Users enter Start Date and End Date while applying for leave.
  • I have a Declare Expression that calculates .TotalDays based on the Start Date and End Date.
  • The calculated value is displayed immediately on the UI, which is the expected behavior.
  • After the case is submitted, the property is saved with the case. I have also optimized the .TotalDays property for reporting.

Issue:
When I use .TotalDays directly in a Report Definition, the column is always blank, even for newly created cases.

As a workaround, I added an Edit Column in the Report Definition using the Convert Decimal Text to Decimalfunction and assigned an alias. This displays the value correctly in the Report Definition.

However, in the Constellation Summary View, I cannot use this alias as a table column because it is not an actual property on the data object.

Questions:

  1. Why is the optimized .TotalDays property blank in the Report Definition even though it is calculated by a Declare Expression and saved with the case?
  2. Is there a supported way to expose a calculated Report Definition column (Edit Column/alias) in a Constellation Summary View? (ref - Property with Declare Expression Not Displaying Values in Report Definition )
  3. What is the recommended approach for displaying a Declare Expression calculated property in both a Report Definition and a Constellation Summary table?

Environment: Pega Constellation

Any suggestions or best practices would be greatly appreciated.

That is actually how Declare Expressions behave depending on their change tracking configuration.

When you run the report definition, system is placing those properties in a page and it runs the declare expression and considers the values present on that page. IF you include the source properties Start Date and End Date in your report definition, then it will make the calculation correctly and returns you the value.

There is also one more solution for it which I would recommend. You can use legacy declare expression and use the below settings in the Change Tracking tab to calculate it only when source properties are changed. This will allow your declare expression to run in UI while you are changing the values but not while running the reports(as the values are not changed and it uses the value present in the DB column instead of recalculating it).