LightningFlowComponents
LightningFlowComponents copied to clipboard
CollectionCalculateController - outputDecimalResult - Returns Integer instead of Decimal
Overview: Based on variable names I believe the decimal result should be a decimal, but it is actually an integer.
Steps to reproduce
Steps to reproduce the behavior:
- Create a collection with a decimal field
- Pass in the collection and decimal field into CollectionCalculateController
- Observe the output is rounded to a whole number
Expected behavior
A decimal should be returned.
Actual behavior
An integer is returned.
I am unable to reproduce this behavior. Please provide more details and an example.
I have since modified the code in my orgs so a detailed reproduction would be difficult.
Basically I had:
- A data table (standard flow data table)
- A currency field in the table (multi-currency not enabled, corp. currency USD, currency field on sObject is 2 decimal points)
- Using the dynamic collection processor to take the selected rows in and summing up the currency field
- The output of the dynamic collection process was piped into a currency formula with 2 decimal points precision. This is the value that was showing as rounded to the nearest dollar
I essentially replaced the objToInteger in my org with
// Convert an object to a Decimal
private static Decimal objToDecimal(Object obj) {
return obj == null ? null : Decimal.valueOf(String.valueOf(obj));
}
and updated the test and now the same currency formula in flow shows non-rounded values.