Starting yesterday (with no changes to scripts/fie...
# suitescript
e
Starting yesterday (with no changes to scripts/fields) all of my free-form text fields that were being set to a number via a script were having ".0" appended to them... The following is not the full code, but should get the point across
Copy code
const customerRecord = record.create({})
customerRecord.setValue('custbody_some_field_id',1234) // <--- where 'custbody_some_field_id' is a Free Form Text field
customerRecord.save()
^ Field would get set to
1234.0
However, adding
.toString()
fixed the issue
Copy code
const customerRecord = record.create({})
customerRecord.setValue('custbody_some_field_id',(1234).toString())
customerRecord.save()
^ Field would get set to "1234"
watching following 1
j
I’ve had this exact thing a few times over the years
seems to be random
e
Has it gone back to working after a period of time?
I updated everywhere to have
.toString()
and now I'm afraid to go back
j
same
the place where I’ve run into rogue
.0
is when trying to return a numeric value that is the internalid as a return parameters in a workflow action script, when the return type is List/Record->somethingorother
if I don’t return it as String(theid) then it appends .0 and breaks shit
for no reason
it’s like NS adds .0 and turns it into a string if it’s a number? but if you pre-string it, it’s ok
I’ve definitely encountered .0 elsewhere too tho
n
@jen have literally fought this all day. WFA script returns integer to an integer WF field. Errors all day on a new approval script/wf
worked great for months in sandbox
j
Honestly just try this:
Copy code
///// WHYYYY DOES THIS HAVE TO BE A STRING???
	    return String(new_ws.id);
b
likely answer is that while the javascript number is being converted for use in the java method, its being converted to a string
and that string doesnt match the javascript string you would get if you converted the number to a string
its also extra likely that this is the kind of thing that will have different behavior between suitescript 2 and 2.1
and also the kind of thing that would have different behavior between client script and server script
n
Either way, this just saved my project