function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sachin kadamsachin kadam 

Send email when Queue reaches certain records

Hello 

I want to send an email (probability with workflow)  when more than 5 cases are assigned to a Queue,
how do we do this?
Fyi i dont want to create a trigger.
Parker EdelmannParker Edelmann
Hello sachin,

Unfortunately this is beyond the power of workflow. You will need to use it's bigger brother, Process Builder. I believe that this can be done using Process Builder and Visual Workflow, but I have a question for you: Do you want this to fire for only the sixth case that is assigned to a queue, or do you want this to fire for every case past the fifth one (i.e. it fires for the 6th, 7th, 8th, etc.)? If you want it to fire for every case past five, then this should be somewhat simple. If you want it to only fire for the 6th case, then this will probably require Apex (which I am not able to code).

Regards,
Parker
sachin kadamsachin kadam
Hi Parker 

thanks for respondiong i need this to be fired if the queue has 5 cases assigned to it and keep sening the email for every additional cases beeing assigned to it where the count of cases is more than 5, (i.e. ifires for the 5th, 6th, 7th, 8th, etc.) if the count gose less than 5 we dont send email.
 
Parker EdelmannParker Edelmann
Hi Sachin,

I have just the solution that you need then. If you need any screenshots let me know and I'll get some for you.

First of all, we need to create a process.
  1. From Setup (Classic view), type "Builder" in the quick find box and click Process Builder.
  2. Create a new process and give it a name and a description.
  3. Click "+ Add Object" and select the Case Object.
    1. Set it to fire only on Create (If you expect cases to switch ownership from one queue to another, let me know and I'll give revised instructions for this.)
    2. Leave the Advanced settings as-is
  4. Create the first (and only) criteria node, give it a name and set the criteria for:
    1. OwnerId IsBlank Boolean false
    2. OwnerId starts with Id 00G
  5. Create an Immediate action and select type "Flows"
We haven't built the flow yet, so click the "build one" link that you see on the action page. It will direct you to the flow landing page. Click "New".
  1. We'll create the variables for the flow up-front.
    1. Create a variable and name it QueueId.
      1. It should be type Text
      2. It should be set to Input only
    2. Create an sObject collection variable named Cases
      1. It should be of type case
      2. It can be left as Private
    3. Create an sObject variable (not a collection) named CurrentCase
      1. It should be of type case
      2. It may be left as Private
    4. Create another variable called NumberOfCases
      1. Set it to type number
      2. Leave it as Private
      3. Set the Default value to 0
  2. We'll also need to create a formula
    1. Name it AddOneCase
    2. Set the Data type to number
    3. Set the formula for {!NumberOfCases} + 1
    4. Drag another Fast Lookup Element onto the canvas
      1. Name it "Find Cases in Queue"
      2. Set it to Lookup Cases where:
        1. OwnerId equals {!QueueId}
      3. For the Variable, select {!Cases}. For the fields to save, select the Id and any fields that you may want to use in the email.
      4. Click OK and connect the previous Fast Lookup to this one
    5. Save early, save often. It's best to save it after every step. Click the save button, name the flow, and choose Autolaunched Flow as the type.
    6. Drag a Loop Element onto the canvas
      1. Name it Loop through Cases
      2. Select {!Cases} as the variable to Loop through
      3. Select {!CurrentCase} as the Loop variable
      4. The sort order does not matter, so you can choose ascending
      5. Click OK and connect the Fast Lookup to the Loop
    7. Drag an Assignment element onto the canvas
      1. Name it Add One Case
      2. For the Assignment, set it to {!NumberOfCases} equals {!AddOneCase}
      3. Click OK
    8. Connect the Loop Element to the Assignment. If a dialogue pops up, select "Next Element"
    9. Connect the Assignment to the Loop Element
    10. Drag a Decision Element onto the canvas
      1. Name it "Determine Number of Cases"
      2. Name the first Outcome "More than 5 Cases"
        1. For the criteria set it to {!NumberOfCases} greater than 5

    Now we're going to configure the email element. You have two choices, use an email alert, or use the Send Email element. After you're done, connect the decision element to the send email element and select "More than 5 Cases" as the Outcome
    If you decide to use an email alert, you'll need to have it premade. I assume that you already know how to create one. If not, let me know. I'll let you decide how to best configure this element

    If you decide to use the "Send Email" element, you'll need to create a Text Template within the flow. To do this, go to the Resources tab in the sidebar and double-click Text Template. Give it a name, and type up the email. Let me know what you would like the email to say and I can help you get any values that you want for it.

    Once you have finished, save the flow, close it, and activate it. Return to Process Builder and refresh the page. Set up the Immediate action for "Flows", name it, and choose the flow you just created. Next, configure the inputs. In this example, we've only set the QueueId field as input. Map it to the OwnerId, save the action, and activate the Process.

    Please let me know if you have questions, and I'll try to address them as soon as possible.

    Regards,
    Parker