Discussions
help me with the following code
function myBeforeLoad( type, form )
{
nlapiLogExecution( 'DEBUG', 'test userevent:beforeload', 'entry of this function' );
if( type == 'create')
{
nlapiLogExecution( 'DEBUG', 'create', 'in create subbranch' );
}
else if( type == 'view' )
{
nlapiLogExecution( 'DEBUG', 'view', 'in view subbranch' );
var oldrecord = nlapiGetOldRecord();
var newrecord = nlapiGetNewRecord();
// nlapiLogExecution( 'DEBUG', 'oldrecord content', oldrecord.getRecordType() + " and " + oldrecord.getId() );
// nlapiLogExecution( 'DEBUG', 'newrecord content', newrecord.getRecordType() + " and " + newrecord.getId() );
if( oldrecord == newrecord )
nlapiLogExecution( 'DEBUG', 'comparison', 'new equals to old' );
var type = nlapiGetRecordType();
var id = nlapiGetRecordId();
nlapiLogExecution( 'DEBUG', 'direct get content', type + " and " + id );
}
else if( type == 'edit' )
{
nlapiLogExecution( 'DEBUG', 'edit', 'in edit subbranch' );
}
}
as the highlighted part, newrecord is the one returned by the server, however, oldrecord is null. how did it come about? as for the blue part, the method getRecordType() could not be executed. why?