Eval java error on automation

Found a bit of an issue im trying to resolve. Using the eval java module and on the first line I am passing a value. i believe the error is because the field has a line break in it so it falsely thinks the close quote is missing. Thoughts on an easy way to resolve?

1 Like

Wow, what a coincidence, someone on our team hit this same problem in the last week or so.

We now have a “remove newlines” action in the Transform Text app you can use to strip out the newlines in the substituted string for the JavaScript expression:

Have installed this action into your system. Looking at your JavaScript, I think it is what you need, since you don’t emit the original value where you need the newlines preserved. So you would map the input value into this action first, then map the output of this action into your JavaScript.

You should also use the “replace text” action also in Transform Text to escape double quotes in your input data by adding a backslash in front of the double quotes. This is b/c any input values that contain double quotes will cause your JavaScript to fail in a similar fashion. This escaping depends on how you define string variables. You have var class = “ARG1” but if you instead had var class = ‘ARG1’ surrounded by single quotes then the replace text action would need to escape single quotes by adding a backslash in front of those.

If for some reason you need to preserve newlines, then a workaround is to use Java instead of JavaScript. I think it is able to handle newlines in input data ok.

1 Like

awesome. thanks. that should do exactly what i need

1 Like