Unable to fetch the fileDescriptor in the Entity Editor Screen

Hi,
Im implementing something like the Settings screen. Where i don’t have an entity browser, but only the entity editor screen. so, on the screen ready method i’ve implemented something like the followiing code to set the Data source.

@Override
public void ready() {

    LoadContext.Query query = LoadContext.createQuery("select e from projectnow$Company e").setMaxResults(1);
    Company company = dataManager.load(LoadContext.create(Company.class).setQuery(query));
    if (company == null) {
        company = metadata.create(Company.class);
    }
    companyDs.setItem(company);

    super.ready();
}

In the Entity i’m having various attributes along with fileDescriptor attribute. It is not fetching… Other attributes are properly fetching, but i’m unable to fetch the fileDescriptor attribute… Im getting an error
IllegalStateException: Cannot get unfetched attribute [imageFile] from detached object

I’ve properly added the fileDescriptor attribute in the view. But even though the attribute is not attached… Please help me regarding this…

Try to use
Company company = dataManager.load(LoadContext.create(Company.class).setQuery(query).setView(“my-view-wth-image-file”)); for loading your entity.

2 Likes

Works as expected… thanks… Ivan…

1 Like