cancel
Showing results for 
Search instead for 
Did you mean: 

Error: could not translate value expression 'session.catalogversions'

pavan-yvs-1
Explorer
0 Kudos
1,845

Hi,

While a custom Cronjob runs, we are getting an error - Error: could not translate value expression 'session.catalogversions'
There are many active search restrictions in the application, whereas this issue is caused by a particular searchRestriction that has below details

Restricted type: DiscountRow
Applies on: CustomerGroup
Filter: ({item:product} IS NOT NULL OR{item:catalogVersion} IS NULL OR {item:catalogVersion} IN (?session.catalogversions))

We are migrating from 2011 to 2205, We have other environments with same code and the restriction in 2011 version, where we do not face this issue. It only occurs in 2205 version.

Session user is admin in RUN AS tab of my cronjob. So since this restriction is on customergroup, it should not be applicable to admin in my understanding.

Any thoughts how can I resolve this without disabling the searchrestriction?

Thanks in advance!

View Entire Topic
YannickRobin
Product and Topic Expert
Product and Topic Expert
0 Kudos

Please check your cronjob is not multi-threaded and you forgot to set the context to the thread.

pavan-yvs-1
Explorer
0 Kudos

Hi yannick.robin ,

Can you please let me know how to do the same. Is it at code level or any property?

Thanks.

YannickRobin
Product and Topic Expert
Product and Topic Expert
0 Kudos

Here is an example of code on how to set the tenant, user and catalog into a new thread.


for (int i=0;i<100;i++) {
executor.execute(new Runnable() {

public void run() {
try {
Registry.setCurrentTenant(currentTenant);
JaloSession.getCurrentSession().activate();
println JaloSession.getCurrentSession().getSessionID();
userService.setCurrentUser(user);
catalogVersionService.setSessionCatalogVersions(catalogVersions);

//put your code here

} finally {
JaloSession.getCurrentSession().close();
Registry.unsetCurrentTenant();
}
}
});
}