+ Start a Discussion
Conrad JoosteConrad Jooste 

Case trigger help

I'm trying to put in place a basic trigger for the auto 'assignment of cases' via communities to ensure that they use the default rule & so that I can remove this checkbox "Assign using active assignment rules" from the page layout.

Here's the trigger code, but it doesn't seem to be working. Any ideas?

**********************************************************************
trigger CommunityCaseAssignment on Case (before insert) {
for (Case c: Trigger.new) {
        if (c.Origin == 'Community') {
           Database.DMLOptions dmlOpts = new Database.DMLOptions();
           dmlOpts.assignmentRuleHeader.useDefaultRule = true;
           c.setOptions(dmlOpts);
        }
        }
}

***********************************************************************
Or are there any other creative solutions around this?
Best Answer chosen by Conrad Jooste
Conrad JoosteConrad Jooste
Check out this link for the answer:  https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001og8&fId=0D53000001dGj7n (https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001og8&fId=0D53000001dGj7n" target="_blank)

All Answers

Ramu_SFDCRamu_SFDC
The below article might help

http://developer.force.com/cookbook/recipe/running-case-assignment-rules-from-apex
Conrad JoosteConrad Jooste
@ramu - looks like you updated this 4 times? Can you delete the extra 3?

The info on that link is not all that helpful.
Ramu_SFDCRamu_SFDC
Hi @Conrad, my bad that was by mistake. Thanks for notifying me about this. 
Conrad JoosteConrad Jooste
Check out this link for the answer:  https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001og8&fId=0D53000001dGj7n (https://success.salesforce.com/_ui/core/chatter/groups/GroupProfilePage?g=0F9300000001og8&fId=0D53000001dGj7n" target="_blank)
This was selected as the best answer