Page 1 of 1

Uncaught SyntaxError: Unexpected token '}'

Posted: Fri Sep 05, 2025 6:05 am
by Paul
Can't figure out where this error is coming from. It happens when clicking into a record from the Browse window. Edit window opens, but gets locked up with this error. I have to move to another window to be able to do anything.
There are no messages in the nuDebug window.

I did an Inspect via Chrome. Console says:

Uncaught SyntaxError: Unexpected token '}'
at new Function (<anonymous>)
at nuform.js:5947:27
at Array.forEach (<anonymous>)
at nuCalculateForm (nuform.js:5938:11)
at nuBuildForm (nuform.js:121:3)
at Object.successCallback (nuajax.js:193:4)
at c (jquery-3.7.1.min.js:2:25304)
at Object.fireWith [as resolveWith] (jquery-3.7.1.min.js:2:26053)
at l (jquery-3.7.1.min.js:2:77782)
at XMLHttpRequest.<anonymous> (jquery-3.7.1.min.js:2:80265)

Re: Uncaught SyntaxError: Unexpected token '}'

Posted: Fri Sep 05, 2025 6:24 am
by kev1n
Open nuform.js and post the contents of line 5947 here.

Re: Uncaught SyntaxError: Unexpected token '}'

Posted: Fri Sep 05, 2025 6:35 am
by Paul
I found the Calc formula that was causing the issue. There were no } in the formula. I will try re-creating the formula.

Re: Uncaught SyntaxError: Unexpected token '}'

Posted: Fri Sep 05, 2025 7:13 am
by Paul
I tried re-creating the formula in question, but got the same error.



Here is entire function near line 5947 of nuform.js:


function nuCalculateForm(setAsEdited) {

if (window.nuEnableCalculation == false) return;

const subformFirst = (a, b) => {
const A = $('#' + a.id).hasClass('nuSubformObject') ? 0 : 1000;
const B = $('#' + b.id).hasClass('nuSubformObject') ? 0 : 1000;
const orderA = parseInt($('#' + a.id).attr('data-nu-calc-order'), 10);
const orderB = parseInt($('#' + b.id).attr('data-nu-calc-order'), 10);

if (setAsEdited === undefined) {
$('#' + a.id).addClass('nuEdited');
}

return (orderA + A) - (orderB + B);
};

const formulas = $("[data-nu-formula]").toArray();

formulas.sort(subformFirst);

formulas.forEach((formula) => {
$(formula).addClass('nuEdited');

const formulaString = $(formula).attr('data-nu-formula');
const format = $(formula).attr('data-nu-format');

let value = 0;

if (formulaString) {
const computeFormula = new Function('return ' + formulaString);
value = computeFormula();
}

const formattedValue = nuFORM.addFormatting(value, format);

$(formula).val(formattedValue);

if (window.nuCalculated) {
nuCalculated(formula, value, formattedValue);
}
});

Re: Uncaught SyntaxError: Unexpected token '}'

Posted: Fri Sep 05, 2025 7:28 am
by Paul
I re-did the Calc for a third time and this time it worked. Strange. Third time is the charm...