Temporary column values from another entity


So what I would need is a column in my Customer’s screen which name is “Status” and the values would came from an another table, let it name Customers Datas.

So I think I need a temporary column on customer’s browser screen. I have no idea how to start it. Any example project? The temporary column’s values will be adjusted based on another entity’s result.

EDIT: I can’t open sales sample project, because I didn’t update, but now I don’t have possibility for that.

Thank you guys so much!


can you show us the entity model for that?

I assume it is like this (and my solution is based on that assumption):

Is that correct? In this case you can just add it to the customer-browse screen like this:
Additionally you need to include the attribute into the view.

Here you can find an example of this:

This is an order screen that should show the customer in the table. I could additionally do something like customer.name given that it is in the order-view.



Hi Mario,
Yes, there is that relation, but I do not want to store the “Status” values, because it changes a lot of. So I think it isn’t useful to store, because there would be often data traffic, updates.

Example: In Customer’s Data the Type = Deleted, Status = applicable then I want to show to user on Customer’s screen that actual customer’s Status is active or in my example inactive.
So I think I need on Customer’s browser screen’s data table one more column which shows the actual status to user, because user can’t reach Customer’s Data.



I guess I should use Custom Datasource. Am I right?
I do not know how to use it only for one column.

Okay, I wrote into the screen descriptor that: , and it’s okay, new column appears with empty value. But how to tell it its value?

Probably in this case you should create a transient value in the Customer class, Then you calculate the return value in the getter: getStatus and set the Annotation property “related” of @MetaProperty (see the docs: Attribute Annotations - CUBA Platform. Developer’s Manual) to the attributes that you actually need in order to calculate the value.

Then you add the transient property to the view of the screen as well as the associated attributes and you can in the customer-browse.xml do it like this: .

The main downside of this is, that you can’t filter on this attribute. I think sorting works, but Filtering not. If this is ok for you, this is probably a good way to go.


Thank you so much!
Should I use for it a Service and a ServiceBean? I guess yes.

How to loop every row?

Or how to pass the actual row to check its Status?

I created an example project for you which shows what i said above.

The customer entity has the attribute status which either is “cool” or “not cool” depending on the amount of the orders it has. The calculation is done via the getStatus method in the Customer.java class:


@Table(name = "CETP_CUSTOMER")
@Entity(name = "cetp$Customer")
public class Customer extends StandardEntity {

    @MetaProperty(related = {"orders"})
    protected String status;

    public String getStatus() {

        String status = "not cool";

        for (Order order: orders) {
            if (order.getAmount() > 100) {
                status = "cool";

        return status;



This is basically everything that is required. As i said, take a look at the correct views and the attributes that are loaded.


cuba-example-transient-property.zip (45.6K)

So I complicated it :smiley:

Thank you so much! :slight_smile:

But unfortunately I get a runtime exception:

IllegalStateException: Cannot get unfetched attribute [orders] from detached object com.company.myproject.entity.Customer-201 [detached].

Somewhy my Status at Customer’s view appears twice, and if I check that and the order’s and save, then I can’t login, I get a “Unsuccesful login! Please contact system administrator”.

Where do you get this exception? - Can you show the stacktrace?

I think the problem is somewhere in the cuba.

In my Customer’s view the status appears always twice. If I rename it, it appears twice. If I check one, both are checked… And in my entity I get that how status name is already exists. If I rename it, I get two status, one with the new name and new functions created for that.

I can’t insert the stacktrace right now, but I believe the problem is somewhere with the view.
Is getStatus() need @MetaProperty ? Because when I build cuba put that there.

I may get your email? I can share more information with you in private.

Thank you.

Are you talking about the example app i gave to you - or do you try to implement it in your own app? Its cuba@die-davids.de.


For one column you can use addGeneratedColumn() method. See its explanation and example in the docs.

Hi Mario,

I am having a similar situation on displaying columns from another entity.
(See the attached database model)
I need to add a column ‘company’ in “Site” browse screen.
I followed the steps that you mentioned:

(i) the “Account” and “Site” table are not related so I created an association with account in the site table and then added ‘company’ attribute in the view.

(ii) then added company column in Site browse screen.

<column id="account.company"/>

Now, I can see the company column but it has no values.
Have I done something wrong?

Please help.