Extended User entity, user.edit view, User edit screen but no way to see new attributes

Hi

Rather frustrating, because I’m probably missing something obvious.

With the help of the doc and the forum here, I extended User entity, user.edit view, and User edit screen. With goal of adding a ‘tenant’ attribute.

For some reason, in extended edit screen I cannot define a new nested DS mapping this new attribute, see screenshot below and attached project.

testrouting.rar (335.8 KB)

image

I found a workaround, maybe that’s how Cuba requires it to be done, you tell me.

In the doc about extending a screen, there is an example of adding an attribute (the most simple), but not a relationwhich requires to override the Datasource of the screen.

Even if this is mentionned in the long list of rules at the beginning of the page this is worth of an example, because while searching here an answer I’ve seen other people struggling with this case.

So the solution is to override the Datasource in the screen using the same name “userDs” than the one inherited, but you cannot do it in Studio, or only the half.

Screenshots below : I tried to change the class from User to ExtUser (which extends User with an additional ‘tenants’ relation). This will make possible to create a nestedDs for the new relation.

Then Studio renames the DS as “extUserDs” => inherited userDs will not be overriden, so you have to go edit the XML and set “userDs” yourself.

There is some kind of inconsistency. I have extended FileDescriptor in another project and this is transparent : you declare a Datasource<FileDescriptor> in your screens, and you have in fact a Datasource<ExtFileDescriptor>, meaning you can downcast entities with no issue. This should be the same here.

image

image

Hi, @michael.renaud

For some reason, in extended edit screen I cannot define a new nested DS mapping this new attribute, see screenshot below and attached project.

The reason is that generated userDs datasource uses default User as entity class. So, to add your custom property you have to set your extended ExtUser as entity class.

There is some kind of inconsistency

There is no inconsistency at all. You are able to downcast to your custom user in a browser or editor screens, but you have to set custom entity class explicitly to add custom attribute.

Regards,
Daniil

Thanks Daniil, I reached the same conclusion.

But don’t you think that Studio could allow the DS name to be edited, henceforth ?

Mike

I’ve created a ticket in YouTrack, but i’m not sure that it will be fixed: YouTrack.

Actually there is a bug in Studio. Datasource id shouldn’t be changed when changing entity class.
It was fixed and will be available in the next release.

Great, thanks to both of you