Schedule a child workflow to be triggered at given time

Hello!

I’m investigating the best way to make a child workflow to be triggered at certain time later on (let’s say at 12:00pm) and only one time.

Parent workflow should run and if all activities succeed a child workflow should be created with a schedule to be triggered at 12:00pm AND parent workflow should be updated to completed.

What would be the best approach to achieve that?
I’ve spent some time reading and I’m not sure if that is possible or what is the best way.

Creating a Cron or a Schedule require to be using the client and connection which I’m not sure it would be a good practice to use that within a workflow (or even if its possible).
Also can Schedules or Cron be triggered only one time, at given time?

I haven’t seen any example or mention showing that a child workflow can be configured and compatible with Schedule or Cron.

I’ve been reading about startDelay, but again, not sure if that can be used on a child workflow? It would require to update temporal version which can led to more work.
This approach would also require to do some calculation to determine how much should it delay to be triggered at 12.

And lastly we have the sleep option, I can put the child workflow to sleep, again needing to do some calculations for it to be triggered at given time.

For the startDelay and sleep options, I also wonder if the parent workflow can go to complete status once the child workflow has spawned.

Any suggestions on which would be the best approach?

1 Like

Would go with starting child workflow async (via startChild) with abandoned parent close policy

parentClosePolicy: ParentClosePolicy.PARENT_CLOSE_POLICY_ABANDON,

and calculate the timer (sleep) time in child workflow.
This way you reserve your child workflow id right away and would allow the parent execution to complete as you mentioned.

I’ve been reading about startDelay , but again, not sure if that can be used on a child workflow?

not currently as it cannot be set in child workflow options

That is what we finally implemented.

We also tried to start the workflow on different namespace therefore couldn’t use startChild either.

Thanks!