Sorry I was developing in the browser, here's the complete solution
function disableAllFields(executionContext) {
var formContext = executionContext.getFormContext();
formContext.ui.controls.forEach(function (control, i) {
if (control && control.getDisabled && !control.getDisabled()) {
control.setDisabled(true);
}
});
}
Make sure you get the execution context too
