Call a CUBA Schedule Task from UI

Hello,

I created several CUBA Schedule Tasks and I would like to know if these one can be called from a UI component (for example a button).

=> If possible, what is the procedure to follow ?

My Objective is to avoid to duplicate my Java Program in both Middleware and WEB Ui interface.

In advance thank you,

Kind regards,

Paul.

I found a solution maybe not the smartest one but works fine :slight_smile:

  public void onBeanClick() {
        List<ScheduledTask> stask = dataManager.load(ScheduledTask.class)
                .query("select t from sys$ScheduledTask t where t.methodName = 'launchexportBatch'")
                .list();
        for (ScheduledTask obj: stask) {
            String a = obj.getBeanName();
            System.out.println(obj.getBeanName());

        }
        ScheduledTask exe = stask.get(0);
        schedulingService.runOnce(exe);
    }

Hi,
When you need to have a logic that is available from the UI - you need to write a middleware service.

Take a look to guide and documentation:
https://www.cuba-platform.com/guides/create-business-logic-in-cuba?_ga=2.115925510.184996481.1574057964-1761876135.1554359697#middleware_services

https://doc.cuba-platform.com/studio/?_ga=2.37454816.1189720628.1569224134-237267920.1554359693#middleware_services

1 Like

Thank you :slight_smile:

I am OK right now !

Paul.