Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi,
I have a service, returning a string, where I send in a comma separated list of values and if I inside a forEach loop try to access a value and assign it as a result I get the error "org.mozilla.javascript.UniqueTag@3a405ae8: NOT_FOUND"
Bellow is a code snipped that is addreviated.
csvInput.trim().split(",").forEach(csv=> {
var result = csv; // This gives the error
I see no reason why it happens, can anyone suggest a fix and explain this error message?
Kindly
Oskar
Solved! Go to Solution.
Hello Oskar,
That “org.mozilla.javascript.UniqueTag@3a405ae8: NOT_FOUND” is a ThingWorx way of saying that your service returned a JavaScript undefined.
I can’t test it right now, but what likely happens here is that var result gets scoped to the lambda function, and is not visible in the outer scope. Logically you should not be able to redefine a variable in a loop. Try to move it out of the loop:
var result = "";
…forEach(csv => { result = csv; });
(sorry, can’t format it on the phone)
Also, consider using CSV extension for parsing CSV files.
/ Constantine
Hello Oskar,
That “org.mozilla.javascript.UniqueTag@3a405ae8: NOT_FOUND” is a ThingWorx way of saying that your service returned a JavaScript undefined.
I can’t test it right now, but what likely happens here is that var result gets scoped to the lambda function, and is not visible in the outer scope. Logically you should not be able to redefine a variable in a loop. Try to move it out of the loop:
var result = "";
…forEach(csv => { result = csv; });
(sorry, can’t format it on the phone)
Also, consider using CSV extension for parsing CSV files.
/ Constantine