Cancel self within workflow and have the status be cancelled

Hi all,

In the typescript SDK i have workflowFoo. I would like workflowFoo to run for 1 week and if we don’t reach a condition, automatically cancel itself.

The former part I have implemented but I’ve yet to find a way to cancel the workflow within itself and have the resulting status be “cancelled.”

Even the example given here:

when I run it as a workflow, has the status set to Completed

Is there a way I can have the workflow cancel itself such that the resulting status is Cancelled?

If you really care about the status, you can cancel the workflow using a client from an activity but otherwise you could cancel the root cancellation scope in the workflow and it should result in a failed status unless you catch the CancelledError.