+ Start a Discussion
SFDC_KMSFDC_KM 

FATAL_ERROR: System.UnexpectedException: commits are not allowed because someone called setCommitAllowed(false), justification: doWorkAndCommit

I am calling a batch in trigger where I a, getting 'System.UnexpectedException: commits are not allowed because someone called setCommitAllowed(false), justification: doWorkAndCommit' error while bulk update. In debug logs the error is indicated for line no underlined below.
if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Processing' OR Status = 'Preparing' OR Status = 'Queued')] < 5){
    ID batchprocessid = Database.executeBatch(new batchClass(contactsId),100);
} else{
        ID batchprocessid = Database.executeBatch(new batchClass(contactsId),100);
        Boolean isSuccess = System.FlexQueue.moveJobToFront(batchprocessid);
        system.debug('---batchprocessid: '+batchprocessid+' & movedToFront: '+isSuccess);
}

Can anyone lead me to the reason for this exception?
 
Raja Bipin Chandra  M BRaja Bipin Chandra M B
Hi, were you able to fix this issue? Can you please share the solution if fixed?

Regards,
Raja