cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Where do I set value for a session attribute that is required during the execution of my cronjobs?

Former Member
0 Likes
1,082

Currently there is ‘salesApplication’ attribute in the session that stays as null for cronjobs. That is causing some solr indexing cronjobs to fail as there is a search restriction being added as part of my work which expects input for ‘(?session.salesApplication)’. What would be the best place to set that attribute in the session so that it works for all the cronjobs?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Likes

Use ImpersonationContext to set the value and execute the code inside impersonationService. Sample Code:-

 final ImpersonationContext context = new ImpersonationContext();
         context.setSite(orderProcessModel.getOrder().getSite());
         context.setUser(userService.getAdminUser());
 
         impersonationService.executeInContext(context, () ->
         {
             warehousingConsignmentWorkflowService.decideWorkflowAction(consignment, templateCode, null);
             waitUntilWorkflowProcessIsNotRunning(workflowModel, timeOut);
             return null;
         });