1

I having trouble in updating the case owner as Queue in Web/Email-to-Case. I wanted to query the email of the sender if its on the list of spam cases (saved in custom setting) then set it to Spam Queue else put in Non Spam Queue. I don't set any Workflow, assignment rule. Below is my code :) (sorry Im still a newbie in coding apex)

Case trigger

2 Answers 2

0

I think there are following logical error in your code.

1) If you do not get any matching record for your SOQL then for loop will not get executed.
2) Due to this non spam queue will be never set.
3) You should write the SOQL without loop to resolve this
4) This code is not Bulkify. See details at https://developer.salesforce.com/page/Best_Practice%3A_Bulkify_Your_Code

0

You can follow this step, hopefully it will work.

You can find that, in the Email-to-Case setting Case Origin in set as 'Email'. For Web-to-Case it will default 'Web'

Rather than using trigger, I think you can play with assignment rule and add relevant condition along with the Case origin to route to a proper queue. There will be single assignment rule to be active, but it can have multiple conditions to route to a queue.

2
  • Yes assignment rule is my primary solution and that is working, but my client wants to maintain the list of spam emails so I prefer to use the custom setting for the records of spam list. Thanks Sir :) FYI. I tried my code in manual creation and hard code the supplied email and its working. So my conclusion is when the case is automatically created, trigger is not working.
    – deks
    Jul 8, 2016 at 5:41
  • Can you please try out using InboundEmail object, refer this link developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… Jul 8, 2016 at 5:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .