Codeless Syntax example?

Mission: CRUD ROOKIE
Task: Update Object With API

I’m struggling to complete via codeless this mission :slightly_smiling_face:

This is the sample Java:
const APP_ID = ‘XXXXXXX-7252-9A9E-FFF3’;
const API_KEY = ‘XXXXXXX-4591-4886-9A54’;
Backendless.initApp(APP_ID, API_KEY);

Backendless.Data.of(‘Person’).findFirst()
.then(function (object) {
// update the object - assign a random value
// to the “age” property
object.age = Math.round( Math.random() * 50 );

// now save the object back in the database
Backendless.Data.of('Person').save(object)
  .then( function (savedObject) {
    console.log( 'Object has been updated' );
  })
  .catch(function (error) {
    console.log( 'Error updating object ' + 
                 error.message);
    throw error;
  });

})
.catch(function (error) {
console.log( 'Error ’ + error.message);
throw error;
});

This is my attempt :frowning:

https://ibb.co/7R3d2rn

any pointers…?

Hi Graham,

What’s missing is a block for saving the object back in the database. Keep in mind that the logic you create is executed in a separate machine (we call it the CodeRunner). The current logic retrieves the first object into the memory on that machine, changes the property and… nothing happens then. So if you save the objecy back, then you should see the task being completed.

Regards,
Mark

Thanks Mark I didn’t expect a response so quick, since you posted the reply I’ve been trying to work out for myself how to complete it…

I still can’t fathom out how to refer to the object I now have in memory… I tried this …
https://ibb.co/Z2JQcJq
but as you know it just creates a blank record in the Persons table. :roll_eyes:

Is codeless frequently used on projects by newbies or do you usually find more advanced devs are using Javascript? I’m not sure if I’m having teething problems, or backendless is too advanced for me…

All you need to do in this case is to create a variable and store the retrieved value there. Variables can be created in the “Variables” section. Here’s the complete codeless logic:

We see codeless used by a wide variety of people, both newbies and advanced developers.

Did you go through the training course on UI Builder we have in our YouTube channel?

Regards,
Mark

Brilliant - I’m off there now ! :stuck_out_tongue_winking_eye: