Start up production in X++

Ever wondered how to start up a production from X++? The code below does the trick :)

protected void startProduction()
{
	ProdMultiStartUp    prodMultiStartUp;
	ProdUpdStartUp      prodUpdStartUp;
	ProdParmStartUp     prodParmStartUp;
	ProdTable           prodTable           = ProdTable::find(<insert_prod_id>);
	;

	if (!this.isProdOprStarted(prodTable))
	{
		prodMultiStartUp = ProdMultiStartUp::construct(null);
		RunBaseMultiParm::initParm(prodMultiStartUp);
		prodMultiStartUp.insert(prodTable, prodParmStartUp);

		prodParmStartUp.StartUpProduction   = ProdStatusOrderedList::newFromOrder().isBefore(prodTable.ProdStatus, ProdStatus::StartedUp);
		prodParmStartUp.StartUpQty          = prodTable.QtySched;
		prodParmStartUp.FromOprNum          = ProdRoute::findFirst(prodTable.ProdId).OprNum;
		prodParmStartUp.ToOprNum            = prodParmStartUp.FromOprNum;
		prodParmStartUp.update();

		prodMultiStartUp.run();
	}
}