Advertisement

09.03.2008 at 01:09PM PDT, ID: 23700579
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.6

Enable Asynchronous Apex feature on Salesforce Unlimited Edition org

Asked by sumprit in Salesforce.com

Hi there,
 
Following is the test class which is throwing the MIXED_DML_OPERATION error:-
 
Link:
// This class includes a test method for Trigger created on JRM_Project__c object.
Global class Automate_ProjectNumberClass {
   
    static TestMethod Void testProjectNumberAutomation()
    {
        try
        {
            //1st Step is to create a new project.
            JRM_Project__c project = new JRM_Project__c(Name = 'name');
            insert project;
           
            //2nd Step get the Region from the USER table, as this is the main criteria.
            User[] loggedUser = [Select Region__c from User where Id =:UserInfo.getUserId()];
            loggedUser[0].Region__c = 'Americas';
           
            update loggedUser[0];          
            insert project; // Once the User Region is determined simply insert the Project record
             
           
            //Updating the exisitng region which is Americas to a new region and again inserting to Project.
            // Similiar steps are repeated for each region.
           
            /*loggedUser[0].Region__c = 'Asia Pacific';
            update loggedUser[0];          
            insert project;
           
            loggedUser[0].Region__c = 'Caspian';
            update loggedUser[0];          
            insert project;*/
        }
        catch(System.DmlException e)
        {
            System.debug(e.getMessage());
        }
    }
}
///////////////////////////////////////////////////////////////////
 
Next, I found a workaround to this problem and it seems like it will work. .This feature is called - Asynchronous Apex. Therefore the same test class was edited in the following way, but the problem is when it gets executed it complains to enable this feature. However, it is a Sandbox with unlimited edition so this feature should be there. Then what could be missing???
 
Here is the code:-
 
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// This class includes a test method for Trigger created on JRM_Project__c object.
Global class Automate_ProjectNumberClass {
   
    static TestMethod Void testProjectNumberAutomation()
    {
        try
        {
            //1st Step is to create a new project.
      insertProject();          
            //2nd Step get the Region from the USER table, as this is the main criteria.
             updateUserRegion('Americas');
        }
        catch(System.DmlException e)
        {
            System.debug(e.getMessage());
        }
    }
   
    static void insertProject()
    {
            JRM_Project__c project = new JRM_Project__c(Name = 'name');
            insert project;  
    }

    @future
    static void updateUserRegion(String region)
    {
            User[] loggedUser = [Select Region__c from User where Id =:UserInfo.getUserId()];
            loggedUser[0].Region__c = region;            
            update loggedUser[0];          
    }
}
////////////////////////////////////////////////////////////////////
 
Please advice.
 
Thanks
 
Start Free Trial
[+][-]09.03.2008 at 01:32PM PDT, ID: 22381646

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.03.2008 at 01:42PM PDT, ID: 22381741

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 06:37AM PDT, ID: 22459634

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 09:10AM PDT, ID: 22461253

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 09:12AM PDT, ID: 22461273

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.12.2008 at 09:21AM PDT, ID: 22461365

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Salesforce.com
Sign Up Now!
Solution Provided By: techhealth
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628