LightningFlowComponents icon indicating copy to clipboard operation
LightningFlowComponents copied to clipboard

CollectionCalculateController - outputDecimalResult - Returns Integer instead of Decimal

Open systemsfixer opened this issue 1 year ago • 2 comments

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.

systemsfixer avatar Nov 25 '24 16:11 systemsfixer

I am unable to reproduce this behavior. Please provide more details and an example.

ericrsmith35 avatar Nov 26 '24 23:11 ericrsmith35

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.

systemsfixer avatar Dec 03 '24 15:12 systemsfixer