How to run a workflow immediately?

I have a scheduled workflow, but I want users to be able to run the workflow immediately without waiting for the scheduled time in Temporal SDK.
How can I do that?
Thank you.

Hello @nnv_saka

You can use the ScheduleHandle.trigger method ScheduleHandle - temporal-sdk 1.20.0 javadoc

There is an example here samples-java/core/src/main/java/io/temporal/samples/hello/HelloSchedules.java at 307a2df3e5adc269fb21d8a7e8afdd001d9ef72d · temporalio/samples-java · GitHub

Let us know if it helps

Antonio

2 Likes

Just a little hint here, for those searching (i only found this option in source, didn’t find it in docs).

You can trigger schedule immediately on creation declaratively, using triggerImmediately option.
TS : sdk-typescript/packages/client/src/schedule-types.ts at 095912ff59f4bb81dcc21a4e845f9e09261e2521 · temporalio/sdk-typescript · GitHub

Java: sdk-java/temporal-sdk/src/main/java/io/temporal/client/schedules/ScheduleOptions.java at 7525c657f757adffe33e0620893f4812740a53cc · temporalio/sdk-java · GitHub