Actually you don’t need to do that, you can simply run the cycleTask state function, and it will
cycle even through the custom states. The issue is that if you trigger it from a query template and the task is not on your current page, the task state won’t sync with your query-task. That I think it is a known bug. And that’s why I decided to not use the cycle task state, and also because I was already AST-parsing the whole task for editing the attributes, so I said why not also handle the task state as an attribute itself.
But why don’t you do tell what you are exactly trying to achieve, so maybe the cycle task state would work for you. Do you have something in mind you want to do, or you were just asking generally?
Essentially looking to write my own widget in HTML/JS that offers a custom view for tasks;
So when there are buttons on my end that I press, I want to be able to manipulate task states with javascript.