You need to sign in to do that
Don't have an account?
sai.sf
DML operation on setup object is not permitted after you have updated a non-setup object
I am getting this error in batch apex "DML operation on setup object is not permitted after you have updated a non-setup object ".
How to fix this.
I got the solution by making the update in 2nd batch apex and calling the 2nd batch apex from finish method of 1st batch.
All Answers
To avoid the above error generally we use @future method.But you are getting this error in batch class.
So we cannot call a @future method in batch.
Unfortunately the workaround is going to be avoiding using batch or update the setup object manually after running the batch.
Mixed DML
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_dml_non_mix_sobjects.htm
Batch best Practices
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_batch_interface.htm
I got the solution by making the update in 2nd batch apex and calling the 2nd batch apex from finish method of 1st batch.