FTS links to Parent entity

I have a Parent Entity “Person” and 3 extended “Customer”, “Employee” and “Dealer”.
Searching from FTS, lets say a “name”, the result list shows “Persons” entities. Is there a way to open the correspondent extended entity editor when I click on a parent link at the FTS result list?

Got a solution here.

Now, I need to find a way to read discriminator value…

I found a solution. Not very elegant, but it works for me.

public class ExtSearchResultsWindow extends SearchResultsWindow {

    @Override
    protected void openEntityWindow(SearchResult.Entry entry, String entityName, WindowManager.OpenType openType) {
        WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
        MetaClass metaClass = metadata.getSession().getClass(entityName);
        Entity entity = reloadEntity(metaClass, entry.getId());
        if (entityName.equals("myapp$Person")) {
            if (entity.getClass().getName().contains("Employee")) {
               entityName="myapp$Employee";
            } else if (entity.getClass().name.contains("Customer")) {
               entityName="myapp$Customer";
            } else {
                entityName="myapp$Dealer";
            }
            metaClass = metadata.getSession().getClass(entityName);
            entity = reloadEntity(metaClass, entry.getId());
        } 
        openEditor(windowConfig.getEditorScreenId(metaClass), entity, openType);
    }

}
2 Likes

Refer for another solution
https://www.cuba-platform.com/discuss/t/fts-cannot-get-unfetched-attribute/6534/15

1 Like