Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Uncaught SyntaxError: Unexpected token '}' Topic is solved

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
Paul
Posts: 21
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 6 times
Been thanked: 1 time

Uncaught SyntaxError: Unexpected token '}'

Unread post 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)
kev1n
nuBuilder Team
Posts: 4445
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 75 times
Been thanked: 487 times
Contact:

Re: Uncaught SyntaxError: Unexpected token '}'

Unread post by kev1n »

Open nuform.js and post the contents of line 5947 here.
Paul
Posts: 21
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 6 times
Been thanked: 1 time

Re: Uncaught SyntaxError: Unexpected token '}'

Unread post 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.
Paul
Posts: 21
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 6 times
Been thanked: 1 time

Re: Uncaught SyntaxError: Unexpected token '}'

Unread post 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);
}
});
Paul
Posts: 21
Joined: Mon Aug 25, 2025 6:03 am
Has thanked: 6 times
Been thanked: 1 time

Re: Uncaught SyntaxError: Unexpected token '}'

Unread post by Paul »

I re-did the Calc for a third time and this time it worked. Strange. Third time is the charm...
Post Reply