Pentaho中的JavaScript错误-无法调用方法"toUpperCase";的null [英] JavaScript Error in Pentaho - Cannot call method "toUpperCase" of null

查看:302
本文介绍了Pentaho中的JavaScript错误-无法调用方法"toUpperCase";的null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//将所有字母设置为大写

// Sets all the letters as uppercase

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,那就不用担心了.

Any idea how to fix this? I would think there would have to be a way to say if value = null then don't worry about it.

推荐答案

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

First you have to think whether it is correct that some values are null or not, such as ae_a_asset_e$manufacture_code.

如果它们可以是null,则可以像这样安全地访问它们(根据需要将此代码扩展到所有其他var):

If they can be null you can access them in a safe way like this (extend this code to all other vars as required):

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

如果它们不能为null,则应首先检查数据完整性,然后运行此脚本(假设它们永远不是null).

If they cannot be null then, your should check your data integrity first and then run this script (assuming they are never null).

这篇关于Pentaho中的JavaScript错误-无法调用方法"toUpperCase";的null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆