Howdy everyone,
I have a scheduled script that is processing a few hundred sales orders daily. It *mostly* works fine, but there are 10-15 events a day where the call to nlapiInitiateWorkflow() results in NetSuite throwing a
RCRD_HAS_BEEN_CHANGED
exception. I've checked and verified there are no updates in my code, it's a dead simple script, 71 lines most of which are infrastructure and plumbing.Considering we can't pass an nlobjRecord reference to the nlapiInitiateWorkflow() method I don't see how I can be the cause of a concurrency fault. I'm tempting to put a simple retry mechanism in place but I'd rather understand WHY this is happening first.Any ideas?As you can see it's pretty basic:try { var workflowInstanceId = nlapiInitiateWorkflow(order.getRecordType(), order.getId(), configurationData.workflowId); SPR.UTIL.Log.audit('Order Approval Review Initiated', String.format('{0} {1} approval review initiated by instance {2}', order.getRecordType(), order.getId(), workflowInstanceId)); } catch(initWFEx) { // If this is the RCRD_HAS_BEEN_CHANGED error we will handle it and log specifically for it if(initWFEx.getCode && initWFEx.getCode().toUpperCase() === 'RCRD_HAS_BEEN_CHANGED') { SPR.UTIL.Log.debug('RCRD_HAS_BEEN_CHANGED Error Encountered', String.format( 'When initiating workflow for {0} {1} the 'RCRD_HAS_BEEN_CHANGED' error occurred.', order.getRecordType(), order.getId())); } else { throw initWFEx; } }