You need to sign in to do that
Don't have an account?

Drawing a blank, how to update cases related to an account, when the account is updated?
Issue I am trying to reslove:
I have a case or two open, it / they are sitting in a queue called "Delinquency Hold".
The first part of the process, this works fine.
The account has a multipick select list called Flags__c, one of the values is Delinquent. When a new case is created, or an open case is edited, the case check's this field on the account, and if the Flags__c includes "Delinquent" it moves the case ownership to Delinquency Hold and displays a large red note across the top of the page.
Here is where I am drawing a blank.
If the account field Flags__c has the value ""Delinquent" removed, I need to have all cases that are Status = Open and Owner = Queue/Delinquency Hold re-visit the the case assignment rules so the case can re-routed/worked.
Idea's, Suggestions?
I have a case or two open, it / they are sitting in a queue called "Delinquency Hold".
The first part of the process, this works fine.
The account has a multipick select list called Flags__c, one of the values is Delinquent. When a new case is created, or an open case is edited, the case check's this field on the account, and if the Flags__c includes "Delinquent" it moves the case ownership to Delinquency Hold and displays a large red note across the top of the page.
Here is where I am drawing a blank.
If the account field Flags__c has the value ""Delinquent" removed, I need to have all cases that are Status = Open and Owner = Queue/Delinquency Hold re-visit the the case assignment rules so the case can re-routed/worked.
Idea's, Suggestions?
If this helps,please mark it as best answer to help others :)
All Answers
http://developer.force.com/cookbook/recipe/running-case-assignment-rules-from-apex
If this helps,please mark it as best answer to help others :)
If this helps,please mark it as best answer to help others :)
I made a few minor modifacations to fit my exact circumstance.
trigger updateRelatedCases on Account(before update)
{
List<Id> accIds = new List<Id>();
List<Case> updatedList = new List<Case>();
for(Account acc:trigger.new)
{
accIds.add(acc.id);
}
List<Case> caseList = [select id, OwnerId from Case where AccountId in:accIds AND OwnerID = '00G60000002Ia7P'];
// Add OwnerID = Delinquent Queue, as only those should be proccesed.
List<Account> accountList = [select id, Flags__c from Account where Id in:accIds AND Flags__c != 'Delinquent'];
// Add Flags__c != Delinquent, So this trigger only enters the for loop for accounts that not Delinquent and should not have cases on Delinquent hold.
if(caseList.size()>0 && accountList.size()>0)
for (Case theCase:caseList) {
Database.DMLOptions dmo = new Database.DMLOptions();
dmo.emailHeader.triggerUserEmail = true;
dmo.assignmentRuleHeader.AssignmentRuleId='01Q60000000Qu6U'; //You can query the id from Assignement Rule object
theCase.setOptions(dmo);
updatedList.add(theCase);
}
if(updatedList.size()>0 )
{
Database.update(updatedList);
}
}
One more suggestion rather than hard coding the Id of queu,you should be querying it and similarily for Assignment Rule id,something like below :-
Queue q = [select id from Queue where name='Delinquent'];