function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
johnc82johnc82 

Assignment Rules API from Custom Controller

I have a function in my controller that creates a new case record.  I need this to go through the assignment rules.  How can I do that with this?

 

public PageReference saveandcreateCase() {

        saveallobjects(); 

          Case c =new case();
          c.Opportunity__c=object.Opportunity__c;
          c.AccountId=object.opportunity__r.accountId;
          c.RecordTypeId='01240000000DkcD';
          c.ContactId=UserContactId;
         insert c; 
          
        object.Case__c=c.Id;

        PageReference createCaseReturntoObject= new PageReference('/apex/ObjectPage?Id=' + object.Id);         
        createCaseReturntoObject.setRedirect(true);
        return createCaseReturntoObject; 
        }

 

bob_buzzardbob_buzzard

Here's a blog post explaining how to do that, courtesy of my fellow mod Ankit:

 

http://forceguru.blogspot.com/2011/12/case-assignment-rules-from-apex.html