A common requirement either using a ribbon button or fired from any other event on the CRM form is to change the statuscode and statecode programmatically.

This is used along with the jQuery library, so don’t forget to add it to the form on load.