UI-Builder Coding Bug

Application ID: 22CC00A4-B93C-CA9C-FFD5-FB6375F62400

Oops. An internal error [6b79899a10a9a85f27b3e7744d389c36] has occurred. We are working on it. Please try again later

Problem description

I was finishing the logical part of a button when at some point the internal error alerts started flashing on my screen.

I think it’s a UI-Builder coding error.
Error Line

Placed the js code produced by the UI-Builder below, you can find the error in the line marked with !!! ERROR LINE !!!

define([], () => ({
  /* content */
  /* handler:onClick */
  async onClick(___arguments) {
    var risparmioInternet, soluzionePrezzoInternet, risparmioGas, soluzionePrezzoGas, risparmioEnergia, soluzionePrezzoEnergia;

function getObjectProperty(object, propPath) {
  if (object == null || typeof propPath !== 'string' || object.hasOwnProperty(propPath)) {
    return object[propPath]
  }

  const propsNamesList = propPath.split('.')

  let result = object

  for (let i = 0; i < propsNamesList.length; i++) {
    if (!result || !result.hasOwnProperty(propsNamesList[i])) {
      return
    }

    result = result[propsNamesList[i]]
  }

  return result
}


  await Backendless.Data.of('SDB').save(({ 'EnergiaPrezzoUtenze': (getObjectProperty(___arguments.context.pageData, 'prezzoEnergia')),'EnergiaConsumoAnnuo': (getObjectProperty(___arguments.context.pageData, 'consumoEnergia')),'GasPrezzoUtenza': (getObjectProperty(___arguments.context.pageData, 'prezzoGas')),'GasConsumoAnnuo': (getObjectProperty(___arguments.context.pageData, 'consumoGas')),'InternetPrezzoUtenza': (getObjectProperty(___arguments.context.pageData, 'prezzoInternet')) }), true);
  if ((getObjectProperty(___arguments.context.pageData, 'prezzoEnergia')) != null) {
    soluzionePrezzoEnergia = (await Backendless.Data.of('SoluzioniUtenze').find(Backendless.DataQueryBuilder.create().setWhereClause('utenza =\'Energia\'').setPageSize(10)))[0];
    risparmioEnergia = (getObjectProperty(___arguments.context.pageData, 'prezzoEnergia')) * (getObjectProperty(___arguments.context.pageData, 'consumoEnergia')) - (getObjectProperty(soluzionePrezzoEnergia, 'prezzo')) * (getObjectProperty(___arguments.context.pageData, 'consumoEnergia'));
    if (risparmioEnergia > 0) {
      ___arguments.context.pageData['risparmioEnergia'] = risparmioEnergia;
    } else {
      risparmioEnergia = 0;
      ___arguments.context.pageData['risparmioEnergia'] = 'Al momento hai un ottimo prezzo!';
    }
  }
  if ((getObjectProperty(___arguments.context.pageData, 'prezzoGas')) != null) {
    soluzionePrezzoGas = (await Backendless.Data.of('SoluzioniUtenze').find(Backendless.DataQueryBuilder.create().setWhereClause('utenza =\'Gas\'').setPageSize(10)))[0];
    risparmioGas = (getObjectProperty(___arguments.context.pageData, 'prezzoGas')) * (getObjectProperty(___arguments.context.pageData, 'consumoGas')) - (getObjectProperty(soluzionePrezzoGas, 'prezzo')) * (getObjectProperty(___arguments.context.pageData, 'consumoGas'));
    if (risparmioGas > 0) {
      ___arguments.context.pageData['risparmioGas'] = risparmioGas;
    } else {
      risparmioGas = 0;
      ___arguments.context.pageData['risparmioGas'] = 'Al momento hai un ottimo prezzo!';
    }
  }
  if ((getObjectProperty(___arguments.context.pageData, 'prezzoInternet')) != null) {
    soluzionePrezzoInternet = (await Backendless.Data.of('SoluzioniUtenze').find(Backendless.DataQueryBuilder.create().setWhereClause('utenza =\'Internet\'').setProperties('prezzo').setPageSize(10)))[0];
    risparmioInternet = ((getObjectProperty(___arguments.context.pageData, 'prezzoInternet')) - (getObjectProperty(soluzionePrezzoInternet, 'prezzo'))) * 12;
    if (risparmioInternet > 0) {
      ___arguments.context.pageData['risparmioInternet'] = risparmioInternet;
    } else {
      risparmioInternet = 0;
      ___arguments.context.pageData['risparmioInternet'] = 'Al momento hai un ottimo prezzo!';
    }
  }
  ___arguments.context.pageData['risparmioTotale'] = undefined;

  },
  /* handler:onClick */
  /* content */
}))
 */ <---!!!!!!!!!!!!!!!!!!!!!!!!!!!!ERROR LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!
}))

What is the name of the page where the error occurs?

Hi Mark,
The page is “SDButenze”
Button with logic “Conferma”

Thanks

Please provide detailed step-by-step instructions for how to get to the page and reproduce the error. Keep in mind that my Italian is assolutamente terribile.

There is a video instructions (WeTransfer - Send Large Files & Share Photos Online - Up to 2GB Free), btw i think it is a coding error from UI-Builder to JS, there is one more final part of code (Code line 65 of WM101 bundle.js)

EDIT: Until this afternoon, everything was working perfectly, after I chained the final two sums they started flashing the alerts and nothing worked anymore :man_shrugging:t2:

Could you please try it now?

Man, u are amazing! Absolutely nobody provides similar assistance in Italy, I love Backendless :heart:

1 Like