Get backendless current user data store response value into a var

function initialize() {
player.src = sounds[‘resetting’];
player.play();
msg = ‘Giddy Up Pardner’;
state.bet = 0;
state.cash = 100;

// i need to change the “100” above to the value of response

var plyscor;

function getObjectProperty(object, propPath) {
if (typeof propPath !== ‘string’ || object[propPath] !== undefined) {
return object[propPath]
}

const propsNamesList = propPath.split(‘.’)

let result = object

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

result = result[propsNamesList[i]]

}

return result
}

plyscor = (getObjectProperty((await Backendless.UserService.getCurrentUser(true)), ‘scor’));

Helllo @joe_joe

Is it code generated by Codeless? Can you show the codeless blocks logic?

Regards

well i need it in js because the code is going into a page stored in backendless but not made on backendless

codecanyon-6Xtdz9rZ-plinko-html5-casino-game.zip (13.1 MB)
so on the game ive attached zip file to, im trying to get the “score” field value of backendless current logged in user and make it be the score in the game

Hello Joe Joe,
Thanks for reaching out! I’d love to help, but I’m having trouble understanding the issue clearly. Could you please share:

  • screenshots that show the issue,
  • a detailed description of the issue you’re experiencing (including steps to reproduce),
  • your App ID,
  • and a page where we can reproduce it (if it’s related to the UI Builder)?

With these details, I’ll be able to investigate and get back to you with the best next steps.
Thank you!

Regards,
Alexander

im trying to get current user field value and insert it into a variable on a page that was not made in backendless

Thanks for the update! I want to make sure I fully understand what you’re trying to do, as it’s a bit unclear on my side. Could you please clarify:

  1. When you say “I’m trying to get current user field value and insert it into a variable on a page that was not made in Backendless”:
  • What page is this exactly? Is it a static site, a custom web app, or something else?
  • Where is it hosted?
  • What do you mean by “insert it into a variable on a page”?
    Do you plan to display it in the UI, store it in a JS variable/state, or send it to another API?
  1. How are you trying to get the current user’s field value?
  2. What’s the expected vs. actual behavior?
  • What do you expect to see, and what happens instead (empty value, error, something else)?
  • If there’s an error, could you share the exact message?

Also, as mentioned earlier, it would really help if you could provide:

  • screenshots that show the issue,
  • a detailed description with steps to reproduce,
  • your App ID,
  • and (if relevant) a page/URL where we can reproduce it (for UI Builder–related cases).

Once I have these details, I’ll guide you step by step.

Regards,
Alexander

backendless hosts it page is html that was not built in backendless ui builder
and when i copy index files into backendless ui builder pages it decides to erase half of my html when i publish the app so using backendless file service i put html index in folder which does not keep user logged in when i navigate to the page because it has different url ( content .backendless ) vs ( appname. api . backendless )

Hello @Mr_Money

You can use the UI builder functionality for pages created in the UI builder. If you are building logic for your own page, I recommend using the JS-SDK Backendless SDK for JavaScript API Documentation

Regards,
Inna