# How do I restart workflow from specific point programmatically?

**URL:** <https://community.temporal.io/t/how-do-i-restart-workflow-from-specific-point-programmatically/4274>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [March 25, 2022, 9:43am UTC](https://community.temporal.io/t/how-do-i-restart-workflow-from-specific-point-programmatically/4274 "2022-03-25T09:43:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Neutron](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/nicholas_neutron/32/1873_2.png) [@Nicholas\_Neutron](https://community.temporal.io/u/Nicholas_Neutron)\
**Post date:** [March 25, 2022, 9:43am UTC](https://community.temporal.io/t/how-do-i-restart-workflow-from-specific-point-programmatically/4274/1 "2022-03-25T09:43:38Z")

</div>

Let’s say I have such a workflow as:

```auto
workflowProps = props
    val extension = try {
      validationStage(order, participant.omsId, omsOrderId)
    } catch (e: ApplicationFailure) {
      null
    }

    if (extension != null) {
      emitCodes(order, participant, deviceId, omsOrderId)

      if (order is MilkOrder && order.paymentType == "1") Workflow.await { orderToClose }
      else Workflow.await(Duration.ofDays(getDayCount(extension))) { orderToClose }

      val remUrl = registrarActivity.getRemUrl()
      remActivity.sendAnnulmentReport(participant, remUrl, deviceId, extension, omsOrderId)
      orderActivity.closeOrderWithBuffers(omsOrderId, orderToClose)
    }

    Workflow.sleep(workflowProps.closeToDeleteDelay)
    orderActivity.deleteOrderWithBuffers(omsOrderId)

```

Whenever it fails with non-retryable error, I want to restart it but from a specific point (last 2 lines of code)

```auto
    Workflow.sleep(workflowProps.closeToDeleteDelay)
    orderActivity.deleteOrderWithBuffers(omsOrderId)

```

Is there a way to accomplish this? Thanks in advance!

---

<div class="post-metadata">

**Author:** ![tihomir](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/tihomir/32/6580_2.png) [@tihomir](https://community.temporal.io/u/tihomir)\
**Post date:** [March 25, 2022, 4:44pm UTC](https://community.temporal.io/t/how-do-i-restart-workflow-from-specific-point-programmatically/4274/4 "2022-03-25T16:44:31Z")

</div>

I think what you are describing is the reset feature. You can reset completed workflow executions to specific `WorkflowTaskStarted` event via tctl (`tctl workflow reset`)  
or via SDK, sample [here](https://github.com/tsurdilo/temporal-java-workshop/blob/main/src/main/java/io/workshop/c1s1/S1WFUtils.java#L318). Note that reset is going to start a new execution (with same workflow id, different run id) and replay history against your workflow code to the specified reset point and then continue execution.

Imo you could maybe accomplish the same thing via business logic and error handling in your workflow rather than relying on failing your workflows. Not sure where you are throwing the non-retryable error in your code, if you can share.
