Question

Change decimal based on currency

Hi all,

 

My case is: change decimal based on currency.

Example: when currency is USD, the decimal is 2; when currency is CAD, the decimal is 0

Pls guide me how to do that

 

Many thanks,

Phuong Nguyen

Like 0

Like

4 comments

Hello, 

 

You can create an attribute and make it dependant on the value of the column you need using Dependencies property. After that you can bind your decimal field to this attribute. Please see the academy articles below: 

https://academy.creatio.com/documents/technic-sdk/7-15/attributes-attributes-property

https://academy.creatio.com/documents/technic-sdk/7-15/adding-calculated-fields

Hi Dennis,

 

Here is my case (Order section): when I change the currency to AUD. The decimal of Total and Payment fields are 0 (it means that the number is 1,140 only)



How can I do that. Thanks

Screenshot link: https://ibb.co/MZtLYFB

 

Dennis Hudson writes:

Hi Dennis,

Here is my case (Order section): when I change the currency to AUD. The decimal of Total and Payment fields are 0 (it means that the number is 1,140 only)

How can I do that. Thanks

Screenshot link: https://ibb.co/MZtLYFB

Hello! 

Unfortunately, there is no way of conditionally changing the decimal precision for the field, it can only be set to a constant. As a workaround, you can create several fields, bind each one to the Amount column value, set the needed precision for each field, and change the visibility of these fields depending on the currency value. 

To do this you can create an attribute for each of the fields and bind fields' visibility to those attributes. To change attributes value when the currency is changed you can use dependency property: 

https://academy.creatio.com/documents/technic-sdk/7-15/attributes-attributes-property

To set the decimal precision of the field you can use decimalPrecision property: 

            {

                "operation": "merge",

                "name": "Amount",

                "values":{ 

                    "controlConfig": { 

                        decimalPrecision: 5 

                    }

                }

            }

Show all comments