How to change document step (workflow)

I need to change a document workflow step on an event.
how can i do that by server script ?