Changing the type of a task using code

Answered here.