问题
// 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();
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.
回答1:
First you have to think whether it is correct that some values are null
or not, such as ae_a_asset_e$manufacture_code
.
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() : "";
If they cannot be null
then, your should check your data integrity first and then run this script (assuming they are never null
).
来源:https://stackoverflow.com/questions/48407801/javascript-error-in-pentaho-cannot-call-method-touppercase-of-null