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
steve_andersensteve_andersen 

Force Case Assignment Rules to Fire

I'm working with the Plone <-> Salesforce.com integration and creating cases from my website. I'm not using web-to-case, just using the API to create Cases and the Related Contact and Account.

Is there any way to fire the default Case Assignment rule when a Case is created via the API? Seems like there are two ways to fire the rules:
  1. Create the Case via web-to-lead
  2. Create the case in the UI, and check the Assignment Rule checkbox
Am I missing the handy-dandy FireAssignmentRule field on the Case?

Thanks,
Steve
werewolfwerewolf
There is a way: put an AssignmentRuleHeader on the request that's inserting the cases:

http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_header_assignmentruleheader.htm#kanchor423
steve_andersensteve_andersen
Thanks for that link.

We've got a form builder that can create arbitrary objects from a website, so I think mucking with the header isn't going to meet my need.

I've voted up an idea for allowing workflow do force recalc:

http://ideas.salesforce.com/article/show/91287/Run_Assignment_Rules_as_an_option_in_Workflow_Actions

Sure would be nice to be able to force assignment either via a data change on the Case or via Workflow or Apex.

Steve
werewolfwerewolf
Why not?  You said you're creating the cases via the API.  Can you not just detect when Cases are the object you're creating and set the header then?  That seems just as easy as setting another field on the object.
Walter@AdicioWalter@Adicio

Thank you werewolf i followed your url to info on assignmentruleid. Thats what I needed thanks much.

 

 

 

The following example uses the useDefaultRule option:
swfobject.registerObject("clippy.d10483e216", "9");
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.useDefaultRule= true;

Lead l = new Lead(company='ABC', lastname='Smith');
l.setOptions(dmo);

insert l;
The following example uses the assignmentRuleID option:
swfobject.registerObject("clippy.d10483e223", "9");
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.assignmentRuleHeader.assignmentRuleId= '01QD0000000EqAn';
Lead l = new Lead(company='ABC', lastname='Smith');
l.setOptions(dmo);

insert l;

 

werewolfwerewolf
BTW for those that are viewing this thread in the post-2009 era, there is now a way to make assignment rules, emails, etc. fire via Apex: the DMLOptions class.
Andy123Andy123

Thanks for the examples.  I've been using the Messaging.InboundEmailHandler to create my own email-to-case functionality and was struggling to figure out how to get the assignment rules to file.  This worked for me!