Cannot get working lookup field on an entity edit form

I created two entities - Contact and Department, the first one has an assosiation field “department” with the second. Then I created an entity edit form ContactEdit and put LookupPickerField to it. But I cannot get normal values in the field and in it’s dropdown list, there are the encoded strings only, like that:
com.company.servicedesk.entity.Department-9d1cb77f-11dc-66af-96f1-bfdf270c1e5a [detached]
The entity Contact has a view “contact-view” where the link “department” is present.
The form ContactEdit has two datasets - Contact and collection Department for the lookup field.
What’s wrong?

Hi Evgeny,

You’ve done everything right, except for one small thing: you forgot to set the instance name for the Department entity. Instance name is the string representation of a record, corresponding to an entity, that will be displayed, for example, in a table cell or, in your case, in a lookup list.

You can set the instance name in Studio: open the Department entity for editing, switch to the INSTANCE NAME tab, select the attribute you want to see in your lookup (for example, “name” or “title” attribute, if any) and move it to the list on the right, then save the changes.

This can also be done be done in the enitity source code by means of @NamePattern annotation, see the documentation here: Class Annotations - CUBA Platform. Developer’s Manual

Thanks Olga! But I don’t remember that I did the same thing earlier with other entities. Maybe before CUBA.Platform update to 6.4 it worked automatically?

It couldn’t work automatically. Possibly you’ve dealt with direct attributes only, which were displayed correctly. All reference attributes, such as Department entity, require an instance name.