Macro not working in komodo 9 : RunEncodedCommand UNDEFINED

I have a little tool I made which just formats my code when I hit command+F instead of having to locate my custom formatter in the right click menu. It also saves the file and restarts apache for me.

I have carried this tool for a few years across KomodoIDE versions as I upgrade. But now in KomodoIDE 9 it no longer works its says that Run_RunEncodedCommand is undef.

Here is the JS code of my tool :

komodo.assertMacroVersion(3);
if (komodo.view.scintilla) { komodo.view.scintilla.focus(); } // bug 67103
var formatter;
var language = komodo.view.language;
switch (language) {
    case 'Perl':
        formatter = '/usr/local/bin/perltidy -l=200 -et=4 -nolq -b';
        break;
    default:
        alert("I don't know how to tidy " + language);
        return null
}

//save current cursor position
var currentPos = komodo.editor.currentPos;
ko.commands.doCommand('cmd_save')

try {
    // Save the file.  After the operation you can check what changes where made by
    // File -> Show Unsaved Changes
    // komodo.doCommand('cmd_save');
    // Group operations into a single undo
    komodo.editor.beginUndoAction();
    // Select entire buffer & pipe it into formatter.
    komodo.doCommand('cmd_selectAll');
    Run_RunEncodedCommand(window, formatter + " {'insertOutput': True, 'operateOnSelection': True}");
    // Restore cursor.  It will be close to the where it started depending on how the text was modified.
    komodo.editor.gotoPos(currentPos);

    ko.commands.doCommand('cmd_save')
    _part = komodo.findPart('command', '.RR - RESTART APACHE')
    if (!_part) {alert("Couldn't find a command called '.RR - RESTART APACHE' when executing macro."); return}
    ko.projects.invokePart(_part);
    ko.commands.doCommand('cmd_vim_cancel')    
}
catch (e) {
    alert(e);
}
finally {
    // Must end undo action or may corrupt edit buffer
    komodo.editor.endUndoAction();
}

Try using ko.run.runEncodedCommand() instead.

That did it. Thanks for the help.