- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 09:30 AM
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!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 09:46 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 09:43 AM
use parseInt() method to convert string to integer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 09:46 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2019 10:05 AM
I really tried fancy scripts to insert a '.' 2 digits in. Thank you for simplifying!