I'm having a weird issue w/ JSON.parse. I have a t...
# suitescript
c
I'm having a weird issue w/ JSON.parse. I have a text field that contains a JSON string. If I do some console code and get the value and use JSON.parse, everything works fine. If I do the same thing in my MR script, i get a syntax error with an unterminated string literal. Since the JSON is valid and it works in the console, i am a bit stumped as to what could be going wrong. Its def coming through as a string and then using JSON.parse on it.
p
could the M/R code be returning a truncated version of the string?
c
ill check the length real quick. Its too long for the log for sure
yep the one in the saved search looks like its only getting 1300 out of 4700 characters
s
you're saying search in console gets it all but MR search returns only 1300?
c
Yes, I had to do a search.lookupFields to get the full text
im gonna try creating the search in suitescript as well and seeing if that gives me a different result as well
s
Curious if it behaves differently in script types other than MR (e.g. scheduled)
p
I know this happens in the UI, i've seen people in some channel sharing formula hacks on how to get multiple fields to substring different parts of the text in order to get all the content in a search. In fact, that was the reason i suggested that searches truncating stuff might be the culprit in the first place.
I wonder if N/query has the same limitation
Googleing around i see people mentioning truncation of long texts... but to 4000 chars, not 1300. That's odd too🤷🏽‍♂️
c
it only fails if you load the search in the mr script. I can load the search in the console and get the full length text as well
1300 is the total # of characters the log and saved search result is showing
this can't be by design
Copy code
1. Console - get field value = OK
2. Console - Search all in code = OK
3. Console - Load search = OK
4. Map/Reduce - Search all in code = truncated
5. Map/Reduce - Load search = truncated
I ran these tests above. Whatever is going on in map/reduce w/ N/search module is truncating the text length but its fine in the console.
Not sure if this is a bug or what
Also tested with the field being a formulatext field and it truncated even more than using the regular field.
s
I know many love MR as some sort of silver bullet, but it would be great to know if this same behavior happens to you in a good old stable Scheduled script.
c
I did not test that one but I would venture to say that it probably has the same type of behavior since its another server-side script
its gotta be a bug
just an update to this, i wrote a quick map/reduce script for a support case. I used the same search and retrieved the same value all within my getInputData phase and the text value was returned full length. Only difference is I am using run().getRange vs a runPaged()
s
never tested in Scheduled Script? I only ask because I have seen MR behave in mysterious ways in the past.
c
I did not. I am pretty confused on this one. Going to see what support has to say
i know i've used this method in the past and others probably use it too so my concern is something non-passive happened and people's stuff broke
really depends on how you're retrieving the data and its not really inconsistent
So as an update, support acknowledged this is a "bug" (they used the word "issue" and never actually said bug) in 2019.2 environments but in the latest release this is not an issue
s
all hail 2020.1
p
netsuite