- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2024 11:20 PM
Hi,
I'm facing an issue with transform map. I have a field in excel sheet "Amount" where user can give numbers. It works well if I enter and transform whole number but when I enter decimal number like 7400.78 the amount on expense line field is setting as 740078.00. However, I see in staging table this as it is 7400.78(field type is string) Adding screenshot as well.
Code in On before script
Need help in troubleshooting this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2024 02:24 AM
Could you try it with this code in your onBefore script?
if (source.u_amount != '') {
var sourceAmount = source.u_amount.toString();
var taskCurrency;
var grFEL = new GlideRecord('fm_expense_line');
grFEL.addEncodedQuery('number=' + source.u_number);
grFEL.query();
if (grFEL.next()) {
taskCurrency = grFEL.getDisplayValue('task.project_currency');
}
var ret = sourceAmount.replace(/,/g, ''); // Remove commas if any
if (sourceAmount.indexOf(".") >= 0) {
var parts = ret.split('.');
var integerPart = parts[0];
var decimalPart = parts[1];
if (decimalPart.length === 1) {
decimalPart += "0"; // Ensure two decimal places
}
ret = integerPart + "." + decimalPart;
}
target.amount = taskCurrency + ';' + ret;
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2024 02:24 AM
Could you try it with this code in your onBefore script?
if (source.u_amount != '') {
var sourceAmount = source.u_amount.toString();
var taskCurrency;
var grFEL = new GlideRecord('fm_expense_line');
grFEL.addEncodedQuery('number=' + source.u_number);
grFEL.query();
if (grFEL.next()) {
taskCurrency = grFEL.getDisplayValue('task.project_currency');
}
var ret = sourceAmount.replace(/,/g, ''); // Remove commas if any
if (sourceAmount.indexOf(".") >= 0) {
var parts = ret.split('.');
var integerPart = parts[0];
var decimalPart = parts[1];
if (decimalPart.length === 1) {
decimalPart += "0"; // Ensure two decimal places
}
ret = integerPart + "." + decimalPart;
}
target.amount = taskCurrency + ';' + ret;
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2024 05:43 AM
Thank you.It is working well @Mark Manders