Pentaho 中的 JavaScript 错误 - 无法调用 null 的方法 "toUpperCase"

标签 javascript null pentaho spoon

//设置所有字母为大写

var str = ae_a_asset_e$manufacture_code.toUpperCase();
var str2 = ae_a_asset_e$serial_no.toUpperCase();
var str3 = ae_a_asset_e$manu_part_number.toUpperCase();
var str4 = ae_a_asset_e$region_code.toUpperCase();
var str5 = ae_a_asset_e$fac_id.toUpperCase();

知道如何解决这个问题吗?我认为必须有一种方法来表示如果 value = null 那么就不用担心。

最佳答案

首先你必须考虑某些值为null是否正确,例如ae_a_asset_e$manufacture_code

如果它们可以为null,您可以通过这样的安全方式访问它们(根据需要将此代码扩展到所有其他变量):

var str = ae_a_asset_e$manufacture_code ? ae_a_asset_e$manufacture_code.toUpperCase() : "";

如果它们不能为 null,那么您应该首先检查数据完整性,然后运行此脚本(假设它们永远不会为 null)。

关于Pentaho 中的 JavaScript 错误 - 无法调用 null 的方法 "toUpperCase",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48407801/

相关文章:

javascript - 尚未在字符串中声明变量

MySQL:在 JOIN 语句中使用 NULL 作为通配符

ubuntu - Microsoft Excel Writer 步骤意外错误 - Pentaho Data Integration 4.4.0

javascript - 从输入加载字符串到跨度

javascript - 如何将图片高度和宽度传递给 html 灯箱

mysql - 为什么在 Doctrine 1.1.2 中使用 DQL 将 "s.d IS NULL"添加到我的 where 子句中(使用 leftJoin)?

postgresql - Pentaho 中的数据哈希

sql - Postgresql 单引号转义

javascript - 将字符串转换为模板字符串

c - 通过将指针设置为 NULL 来初始化 C 中的堆栈