1

I am building a complex case management platform for an airline client for whom all cases must be approved BEFORE they are assigned to queues.

We note that because of sequencing within SFDC that the field update in the final approval actions (approval status=Approved) is not detected and needs a further EDIT & SAVE to happen on the case to cause the assignment rules to fire and correctly assign the case to the required queue.

In summary - ideas sought on how to get the assignment rules to fire at the end of or as consequence of an approval process field update (will consider apex if needed).

  • Can you post the picture of workflow field update configuration screen in this question – Santanu Boral May 13 '17 at 14:42
  • Hi @Michael Cunningham, welcome to SFSE! Please take a moment to visit help center, scroll through tour, and read How to Ask. There is no need to mention help or thanks in your posts. include screenshots, code (when applicable) so others can better assist you. Thanks – glls May 13 '17 at 15:02
1

Create a checkbox field like isApproved and during final approval action update this field from workflow field update.

Since you are using Assign using active assignment rules checkbox to fire assignment, which cannot be automatically possible after workflow field update as you are not in UI.

So, you need to write an after update trigger to fire assignment rule:

trigger CaseAssignment on Case (after update) {
    List<Case> caseList = new List<Case>();

    if(Trigger.isAfter && Trigger.isUpdate){
        for (Case caseObj : Trigger.new)
        {
            Case oldCase = Trigger.oldMap.get(caseObj.id);
            if (!oldCase.isApproved__c && caseObj.isApproved__c) {
                caseList.add(new Case(id = caseObj.id));
            }
        }
    }
    Database.DMLOptions dmo = new Database.DMLOptions();
    dmo.assignmentRuleHeader.useDefaultRule = true;
    Database.update(caseList, dmo);
}

Refer Triggers and Order of Execution

If the record was updated with workflow field updates, fires before update triggers and after update triggers one more time (and only one more time), in addition to standard validations. Custom validation rules, duplicate rules, and escalation rules are not run again.


Approval Process setup:

If Type is Electronic it will be submitted for approval and after getting approved, isApproved field will be updated to true.

approval

Case assignment rule:

assignment rule

Case record during submission for approval

during submission

Case is assigned to queue after getting approved, by virtue of after trigger to fire assignment rule.

case after approval

  • Thanks SanatanuTry this - I think you will be surprised (as I am) at the outcome. – Michael Cunningham May 13 '17 at 17:33
  • Sorry unsure how to upload pics here but be assured the field update is already set to reevalute workflow rules - that is not the issue. I have read on forums that this IS normal and down to that fact that Assignment rules run BEFORE field updates (if not so - please advise) – Michael Cunningham 8 mins ago Due to validation that must take place before Approval we are using a custom button to call the Approval process. Would it be possible to cause an event AFTER the approval that could cause the assignment rules to fire? any thoughts? – Michael Cunningham – Michael Cunningham May 13 '17 at 17:35
  • Yes, that is possible, assignment rule fires after "after trigger" so, you need to update the field value so that after trigger will fire followed by assignment rule – Santanu Boral May 13 '17 at 17:44
  • I have updated my answer and I have checked it is working fine and assign to queue through assignment rule which is initiated through after update trigger. If this solves your purpose then accept the answer, so that others may find this useful. If you need any further help, I could able to post all the screenshots by which I have solved the problem. thanks – Santanu Boral May 13 '17 at 20:17
  • 1
    Gave this after-update trigger a go in my developer org and its working a treat!!. Great work Santanu - cant thank you enough for this ingenious solution. – Michael Cunningham May 14 '17 at 9:27
0

Did you check this feature in approval process ? enter image description here

  • Sorry unsure how to upload pics here but be assured the field update is already set to reevalute workflow rules - that is not the issue. I have read on forums that this IS normal and down to that fact that Assignment rules run BEFORE field updates (if not so - please advise) – Michael Cunningham May 13 '17 at 17:26
  • Due to validation that must take place before Approval we are using a custom button to call the Approval process. Would it be possible to cause an event AFTER the approval that could cause the assignment rules to fire? any thoughts? – Michael Cunningham May 13 '17 at 17:31
  • As @ Santanu Boral write. Create "after trigger". – Adamo May 13 '17 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.