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)
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.
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
-
- nuBuilder Team
- Posts: 4447
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 488 times
- Contact:
Re: Uncaught SyntaxError: Unexpected token '}'
Open nuform.js and post the contents of line 5947 here.
Re: Uncaught SyntaxError: Unexpected token '}'
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 '}'
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);
}
});
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 '}'
I re-did the Calc for a third time and this time it worked. Strange. Third time is the charm...