Okay I'm having a really annoying thing I'm trying...
# suitescript
c
Okay I'm having a really annoying thing I'm trying to debug. So, I have a function which iterates through a lot of items, and I'm having trouble with some of the items. This is an example of an item I'm having trouble with. I have created a key value pair, which holds this:
Copy code
var KeyValueobj = {
    "Stainless steel plate EN 1.4301 0-3mm >2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_03b2000w,
    "Stainless steel plate EN 1.4301 0-3mm <2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_03s2000w,
    "Stainless steel plate EN 1.4301 0-3mm =2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_03e2000w,

"Stainless steel plate EN 1.4301 4-12mm >2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_412b2000w,
"Stainless steel plate EN 1.4301 4-12mm <2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_412s2000w,
"Stainless steel plate EN 1.4301 4-12mm =2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_412e2000w,

"Stainless steel plate EN 1.4301 >15mm >2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_15b2000w,
"Stainless steel plate EN 1.4301 >15mm <2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_15s2000w,
"Stainless steel plate EN 1.4301 >15mm =2000mm wide": recordSetPricesItemObj.custrecordss_p_1403_15e2000w,

"Stainless steel plate EN 1.4401 >15mm >2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_15b2000w,
"Stainless steel plate EN 1.4401 >15mm <2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_15s2000w,
"Stainless steel plate EN 1.4401 >15mm =2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_15e2000w,

"Stainless steel plate EN 1.4401 0-3mm >2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_03b2000w,
"Stainless steel plate EN 1.4401 0-3mm <2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_03s2000w,
"Stainless steel plate EN 1.4401 0-3mm =2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_03e2000w,

"Stainless steel plate EN 1.4401 4-12mm >2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_412b2000w,
"Stainless steel plate EN 1.4401 4-12mm <2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_412s2000w,
"Stainless steel plate EN 1.4401 4-12mm =2000mm wide": recordSetPricesItemObj.custrecordss_p_14401_412e2000w,
}; I'm searching through a record's fields in NetSuite and then I get their values and then pair those values with the correct field name. I have created this test:
Copy code
if (bomItem.displayname == "Stainless steel plate 1.4301/1.4307 t=10 EN 10088") {
    log.debug("CHECK1 : " + bomItem.custitem12)
    log.debug("CHECK2 : " + parseFloat(KeyValueobj["Stainless steel plate EN 1.4301 4-12mm >2000mm wide"]).toFixed(2))
    log.debug("CHECK3 : " + parseFloat(KeyValueobj[bomItem.custitem12]).toFixed(2))
    log.debug(bomItem.custitem12 == "Stainless steel plate EN 1.4301 4-12mm >2000mm wide")
}
Results:

check1 = "Stainless steel plate EN 1.4301 4-12mm >2000mm wide"
check2 = 26
check3 = NaN
check = false
This makes no sense in my head, why when I compare 2 identical strings they are not equal? I have tried to check for whitespaces or test with regex and deleted all whitespaces then compared and still == false.. I have also tried this:
Copy code
log.debug("CHECK6 : " + parseFloat(KeyValueobj[bomItem["custitem12"]]).toFixed(2));
I'm experiencing this bug on those display names. Can someone help? I have tried using toString(), Stringify(), deleting all whitespaces with regex, tried to use normalize, also tried using unescape()
b
compare character by character using charAt
if they are all the same character, then I would check String primitives and String objects, though that was more of a problem in ss1
c
message has been deleted
Im geetting weird results... when im printing the above i get this string
message has been deleted
when im printing this i get
,
message has been deleted
and i print this
message has been deleted
i get this
message has been deleted
so it seems like "<, >", will be translated to < &gt
b
not very weird, there are specific requirements around displaying html control characters in html
c
Yea i know
but, is there a method to sanitize the strings?
b
either escape your scripts
or unescape netsuite's strings
c
how..
already tried using so many different methods
sanitize, normalize
message has been deleted
escape functions, but still does not work
b
c
message has been deleted
message has been deleted
For real,
message has been deleted
message has been deleted
still false
no matter what i do
b
you want to unescape netsuite's string
not escape it
c
how
b
after you are done, you should probably double check your work using charAt
c
i used replace like you said
sry , but im confused about this, felt like i have tried everything
unescape(string)
b
use replace, then double check your work using charAt
c
i did use replace??
b
and did you use charAt afterwards?
c
message has been deleted
No
b
replace your string, then double check to see if each individual character matches
if its not, you arent replacing correctly
c
message has been deleted
message has been deleted
So this pops up aswell
thats not right
message has been deleted
between ">" and "2"
message has been deleted
finally thank you so much!
your method really helped in with debugging
b
was the extra : in your string or netsuite's
c
in the string
it was in the string that i pull from netsuite
c
You could have just done what I suggested and rewrite it to use IDs, if possible
c
Yes, i tried, but it is not possible
yes the stock category values have ID's, but i cant access that ID from the record FIELD, so i would have to search through the stock category list, and compare the stock category names with the values from the record, and boom then the same problem is present again
Trust me, since i expereinced problems with comparing the stock category names i looked for other ways to do this, and i found none. The only work around would be to look at indivial non inventory item, but that would just add 100 more variables
so that would be a bad solution, but now that this works its fine, and yes if you could use ID's that would be better but unfortunately i could not figure out on how to do this, neither could my colleague