Transform Map -change string number to decimal for currency

Julie Peters
Kilo Explorer

I am importing a JSON file as a data source and transforming successfully except for one item:  A number in the file that is a string needs to convert to a decimal so it shows correctly as currency.  For example, if the number in the file is

cost= 12345

I need the transform script to add a decimal at 2 places- so the desired result would be 123.45

I do not need scripts to make this a currency value as the target field (currency) already assumes the cost is $12345.00.  It is a matter of changing the source number. 

Please advise and thanks!

1 ACCEPTED SOLUTION

Alikutty A
Tera Sage

Hi,

If I understand your issue correctly, you can add the following in your on Before transform map script.


 target.currency_field = source.u_cost/100.0;  //Replace with proper field names

View solution in original post

3 REPLIES 3

Yogi3
Kilo Guru

use parseInt() method to convert string to integer

Alikutty A
Tera Sage

Hi,

If I understand your issue correctly, you can add the following in your on Before transform map script.


 target.currency_field = source.u_cost/100.0;  //Replace with proper field names

Julie Peters
Kilo Explorer

I really tried fancy scripts to insert a '.' 2 digits in.  Thank you for simplifying!