I also have the same - afterSubmit after creating custom record and it fails
In my case the record I have is called Contract, its ID is customrecord26
The line is :
var ContractID = nlapiGetRecordId();
nlapiSetRedirectURL('RECORD', 'customrecord26', ContractID);