Passing parameters to a method launched by schedulingService

Hi everyone.

Mu problem of the day is the following. In a Bean I have a method doSomething(String myParameter).
I want to launch this method from the UI, when the user clicks on a button. I’m using the schedulingService like below

List stask = dataManager.load(ScheduledTask.class)
.query(“select t from dumbo_sys$ScheduledTask t where t.methodName='doSomething”)
.list();
ScheduledTask exe = stask.get(0);
schedulingService.runOnce(exe);

My question is how can I pass the parameter ‘myParameter’ to the method when I run it ? I didn’t find a lot of documentation about his…

Help much appreciated. Thanks in advance.

Hi,

When you need to invoke a piece of business logic from the UI screen, you should use a middleware service.

I’d recommend you go through this guide:
https://www.cuba-platform.com/guides/create-business-logic-in-cuba?_ga=2.77178325.1943661030.1576563605-1101315617.1531766830#middleware_services

see also:
https://doc.cuba-platform.com/manual-7.1/services.html
https://doc.cuba-platform.com/studio/?_ga=2.37454816.1189720628.1569224134-237267920.1554359693#middleware_services

Hi
I saw these already (you mentioned them to PA Bonlieu). However, it doesn’t answer my question.

Regards

You can not pass custom parameter values when calling SchedulingService.runOnce().
Parameter values are specified in the UI, in the Scheduled Task Editor, and saved into the Scheduled Task itself.
image

Trying to use SchedulingService to launch method from the UI - is not the right way to do it.