You need to sign in to do that
Don't have an account?
akallioWiley
Getting Custom Chatter Action to work with Case Assignment Rules?
I created a custom chatter action to create a Case from a custom object. Everythig works fine except for the fact that the Case Assignment rules didn't kick-in.
My 2 options for assigning the case were to use workflow rules or write a trigger. I went with the trigger because I have 5 and counting assignment rules and I don't want to create a workflow rule for each.
The trigger works fine too. The issue is that when the trigger is used the resulting ChatterFeedItem is not created....once the user hits 'Submit' the case is created, but the Chatter post is not created. So, I'm looking for ideas on how to get that chatter post created.
Here is the trigger's logic:
if(trigger.isInsert && trigger.isAfter) {
//This will ensure that Case assignments are run even Cases are created through Chatter Actions or through some other service.
//Fetching the assignment rules on case
AssignmentRule AR = new AssignmentRule();
AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
//Creating the DMLOptions for "Assign using active assignment rules" checkbox
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
Set<Id> newCaseIds = new Set<Id>();
List<Case> newCases = new List<Case>();
for(Case newCaseId : trigger.new) {
newCaseIds.add(newCaseId.Id) ;
}
for(Case newCase : [select Id from Case where Id IN :newCaseIds]) {
newCase.setOptions(dmlOpts);
newCases.add(newCase);
}
update newCases;
My 2 options for assigning the case were to use workflow rules or write a trigger. I went with the trigger because I have 5 and counting assignment rules and I don't want to create a workflow rule for each.
The trigger works fine too. The issue is that when the trigger is used the resulting ChatterFeedItem is not created....once the user hits 'Submit' the case is created, but the Chatter post is not created. So, I'm looking for ideas on how to get that chatter post created.
Here is the trigger's logic:
if(trigger.isInsert && trigger.isAfter) {
//This will ensure that Case assignments are run even Cases are created through Chatter Actions or through some other service.
//Fetching the assignment rules on case
AssignmentRule AR = new AssignmentRule();
AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
//Creating the DMLOptions for "Assign using active assignment rules" checkbox
Database.DMLOptions dmlOpts = new Database.DMLOptions();
dmlOpts.assignmentRuleHeader.assignmentRuleId= AR.id;
Set<Id> newCaseIds = new Set<Id>();
List<Case> newCases = new List<Case>();
for(Case newCaseId : trigger.new) {
newCaseIds.add(newCaseId.Id) ;
}
for(Case newCase : [select Id from Case where Id IN :newCaseIds]) {
newCase.setOptions(dmlOpts);
newCases.add(newCase);
}
update newCases;
Is that a before trigger of after trigger? We can not invoke assignment rules in before triggers. Solution is to implement the assignment rule code in the "after" trigger instead of the "before" trigger.
The assignment rules work fine with the trigger...the trigger is an after trigger.
The issue is that the Chatter feed item that should be inserted when the user clicks the submit button on the Chatter Action does not get inserted when this trigger is active.
Could you share code? Also try checking debug logs for the submit button event.
Click path for debuig logs: Setup|Administration setup|monitoring|Debug logs