Pentaho/Javascript:如何将字段值(unitPrice)从负整数更改为正整数

Pentaho/Javascript: How to change field value(unitPrice) from negative integer to postive integer?

本文关键字:整数 unitPrice Javascript 字段 Pentaho      更新时间:2023-09-26

在Pentaho程序中,使用Modified javascript步骤。使用product.csv文件,在unitPrice字段中,一些整数为正,另一些为负。在javascript中,如何在其中键入?

这是我打到目前为止的例子,但仍然是一个错误。

 if(unitPrice.getInteger() < 0)
{
    unitPrice.setValue(var) = Math.abs(unitPrice.getInteger());
}
  1. 使用thg435建议的代码:

    单价setValue(abs(单价));

  2. 检查"Modified Java Script Value"组件中的"Compatibility mode"

问候Mateusz