Backendless Support
 
Solved

javascript BL syntax changed without warning (in email sending)

In our shared cloud server app we detected sudden break in email sending, upon looking at log I stumbled across

"ReferenceError: Bodyparts is not defined"

I found that

var bodyParts = new Bodyparts();

now should be

var bodyParts = new Backendless.Bodyparts();

I updated my code and now it's working as before (previous version of code was taken directly from documentation, nothing fancy on my side).

But I must say - guys, it's not cool to change your SDK without any warning.

Leave a Comment

Comments (10)

photo
1

What version of backendless server (3 or 4) and version of JS SDK you use?

Firstly, it sounds strange, because in documentation (https://backendless.com/docs/js/doc.html#messaging_sending_email_rest) i see the line

var bodyParts = new Backendless.Bodyparts();

And secondary, it is recommended to use namespace 'Backendless', because only this object is guaranteed to be available from global namespace.

photo
1

I'm using version 4 app.

I'm aware that it's now have "var bodyParts = new Backendless.Bodyparts();"

originally it was "var bodyParts = new Bodyparts();" I don't know when it changed, but it was working fine in that way until recently. And then it stopped without any warning

photo
1

I wrote above that you should avoid to use direct access to the object.

"it is recommended to use namespace 'Backendless', because

only this object is guaranteed to be available from global namespace."

The example in documentation say the same.

photo
1

I love you guys. Every time I write something in this support forum I have to convince one of your team that it's really not my dummy error. And this is exhausting.

I didn't asked how to handle sending email properly, cause it's written in current documentation correct. I told you that you changed something in your side that it's stopped working and you have to sent warning when you do something like that. Like deprecation warning or something. There wasn't any info about that in 3->4 migration document either.

photo
1

Yuriy we are so sorry for inconvenience. –źnd we do not want to blame you for the dummy errors. If your code had been working well and then stopped to work then something happened on our side.

From my side i only want to give you an advise not to use global 'Backendless' namespace to avoid strange problems.

And thank you for your attentiveness.

With all respect, Backendless team.

photo
1

Yuriy, how do you import the backendless library into your code? Is it via npm or this?

photo
1

It's "standard" Business Logic project, means it was auto-generated from Backendless dev console. So, I guess I would say "via npm".

My package.json is

{

"name": "SW-servercode",

"version": "1.0.0",

"scripts": {

"debug": "coderunner debug",

"deploy": "coderunner deploy"

},

"devDependencies": {

"backendless-coderunner": "^4.3.0-beta"

},

"license": "MIT",

"dependencies": {

"paypal-rest-sdk": "1.7.1",

"request": "2.81.0",

"request-promise": "4.2.1",

"xml2js": "0.4.17",

"xml2js-es6-promise": "1.1.1"

}

}

from time to time I also run "npm update", currently coderenner version is "CodeRunner(tm) Backendless JavaScript CodeRunner v4.4.0"

photo
1

I would recommend prescribing a specific version of CodeRunner (which bundles Backendless SDK for JS). This way you'd be protected from surprises.

Regards,

Mark

photo
1

I see. I thought it was expected from developer to update his codeRunner, for shared cloud app, since cloud backendless is updated by you and I thought without codeRunner update there will be errors due to "out of sync" versions

photo
1

You're right, I was under impression you're working on your Managed installation.

photo