UI builder with Codeless Logic

Hello guys, I came across a problem and I really dont know how to attack it.
Im am trying to get some kind of logic from a Backendless db to display in the front end.

In the DB there are 2 tables:
Activities ( Image, name, description, category)
Categories (category_image, category)

In the front end there is an API call (get all activities) when the page loads, and I am trying to build a logic on the image design

If Activity.image is empty,
then display category_image instead.

But since the image is already binded, how to change that bind?
And how to target a relational value from the database, since the “get all Activities” category is linked to category table and the image posted under the category table, not under Activities (Image 2 and 3).

Hi Rafael,

I assume you’re using a Block or a Container with Dynamic List Behavior and there is an Image component inside of it. Could you please attach a screenshot showing how you configured data binding for the image source?

Regards,
Mark

1 Like


The “bild” is a swedish word for image.
The logic is, when bild doesnt exist, display kategori_image.

Instead of binding your image source URL to a property, you should add logic for that data binding:

In there it would look something like this (the property names must be corrected). Also make sure to load the related categories when you fetch activities, or the logic will result in an error:

Regards,
Mark

1 Like

It seems not working.

The result is a white page.

This is why it is not working:

Unfortunately still not working.

Something is bugging it out. Can’t really understand what.

Please show a screenshot of how you retrieve the Activities objects.

On Page load.

Looks like you missed the following comment:

1 Like

Yes, I did miss out that.

How should I approach it?
I believe I should create a list of “Categories” and store it in a variable “kategorier” on page enter and then set the variable on page data with the list.

Then should I “Get the property (kategorier)” from Page Data, not from “testContainer Item Data” since it’s not stored there… Am I complicating this too much? Should I store the categories In “testContainer” even if testContainer already has events data?

I know I am doing something wrong, really trying to get my head around this. :sleepy: I am so sorry if I sound dumb… Coming from Bubble.io this is more complex than I expected.

It is not complex at all, it is more powerful and gives you more choice, as a result, it is easier to get lost. Have you gone through our training course on YouTube?

Here’s how to load related objects along with the primary ones:
UI Builder - ConsoleDemo - Backendless 2022-01-24 17-26-50

Regards,
Mark

1 Like

Hi mark, yes i have watched the Youtube tutorials, it seems so easy and simple on the tutorials until I start to work on the application…

Something is not right, I did that and I am getting a white screen again. The call is correct and I get the information but it’s crashing my frontend.

After some testing I found out that the problem is on this line.

When I disable it, it works perfectly except that it doesn’t bind the category_image, but the information is fetched on the “Network”.

What can be the problem?

Another information is that I have bound category text as “aktivitets_kategori.kategori_namn”. Can that be the problem? It works properly in the frontend…

Hi Rafael,

Please try to output in the console (using Print block) the contents of testContainer Item Data.
Maybe you get the data in another form than you expect.

Also take a look at the block with the text aktivitets_kategori - it looks like there is a redundant space in the beginning

Regards,
Viktor

I am getting a 400 (Bad Request)

I apologize, what do you mean with space in the beginning? you the Element in the User Interface or in the Logic Interface?

Update:
When I use this logic on the image it comes the crash.

As I understand, its not reading the “kategori_image”

So I guess something is wrong in this code block.

Looks like there is extra space here:

1 Like

I found the problem.
In some of the events in the BDB the Category was empty, so it was not reading it.
It got fixed as soon I add the proper categories.

Thank you for the support!

1 Like