Skip to content

Reassign the case back to the queue using the CaseHistory

If you want to do with the formula fields then you can check out the article by my friend Usman Ali on Salesforce help.

Description

Sometimes, we have a requirement to re-assign the case back to the initial queue for example if the case status is updated to “Stalled” then reassign it to the queue that was assigned to the case at the time of creation.

Example

  • Queue Name: Tier 1 Support
    • It gets assigned to the case whenever the case is created.
  • John Smith is a part of the queue that picks the case via Omni channel for example and the case gets assigned to John. 
  • After some time due to workload, John updated the case to the “Stalled” status and he wants anyone else on his team to work on this case instead of him.

Resolution

  • Since we’ll be using the Case History object to get the initial queue assignment so the case history must be turned on.
  • Create a record-triggered flow that runs whenever the case is updated to “Stalled” and query to the initially assigned queue from the case history object.
    • Setup | Process Automation | Flows
    • Click on the New Flow button and select the Record-Triggered Flow.
    • Follow all steps in the below screenshot to set the trigger whenever the case is updated to “Stalled” and the case is not assigned to the queue.
      • Select Case in Object
      • Select A record is updated in the Trigger the Flow When: section
      • Select Custom Condition Logic is Met in the Condition Requirements section.
        • Set the 1 AND 2 AND NOT(3) in the condition logic
      • Select Fast Field Updates in Optimize the Flow for:
      • Click on the “Done“ button
  • Now, follow all the below steps.
    • Click on the “+” button and add a Get Records element
    • Select Case History in Object
    • Select Owner for the Field and $Record > Case ID for the CaseId under the filter section
    • Set the Sort Order Ascending by CreatedDate
    • Select All records in the How many records to store section
    • Click on the “Done“ button
  • To make sure that it stops in case no owner change history is found, add a decision element.
  • If owner history is found then add a loop element to loop through history records under “Found” node.
  • Now, add a decision node inside the loop element. 
    • {!Loop_Through_History.OldValue} Starts With 00G
  • If the Decision outcome is True then set the {!Loop_Through_History.OldValue} in the {!$Record.OwnerId} variable.
    • Select End under the assignment element to stop the flow if the queue is assigned.

Complete Flow:

Note: The Retention Limit for Field History Data Is Now Enforced and field history data is only guaranteed to be retained for 18 months if your org was created after June 1, 2011.