I have default company value stored in UserSessionSource, how can I use as parameter in declarative datasource to get a list of materials in the material,browse screen that are only related to this default company?
I tried like this but seems not right!
In material.browse
@Override
public void init(Map<String, Object> params) {
Company defaultCompany = userSessionSource.getUserSession().getAttribute("defaultCompany");
}
in XML to define datasource
select e from erp$Material e where e.company = :param$defaultCompany
I also tried both in init
Company defaultCompany = userSessionSource.getUserSession().getAttribute("defaultCompany");
materialsDs.setQuery(
"select e from erp$Material e where e.company.id = :param$defaultCompany");
materialsDs.refresh();
Thanks for your help.