2

I got a project which needed to setup an public community as an endpoint to receive JSON messages (URL post method). My community home page got a restful apex class to receive message and process it like create or update a Case based on this message.

In my salesforce environment, I already setup an assignment rule to put new or updated Case above to a queue, this queue will assign Case to omni-channel or Live agents.

in my case, assignment rule alway automatically trigger when I update a Case even I haven't put any related code into my apex class. I know if I want to adopt any assignment rule, I need to put some code in my apex class such as following:

        Database.DMLOptions dmlOpts = new Database.DMLOptions();  
        AssignmentRule AR = new AssignmentRule();
        AR = [select id from AssignmentRule where SobjectType = 'Case' and Active = true limit 1];
        dmlOpts.assignmentRuleHeader.assignmentRuleId = AR.Id;
        Case cs = new Case();
        cs.setOptions(dmlOpts);

based on my testing, every time I update a Case, community Site Guest User (Customer) always change updated Case ownership from me to Case queue.

enter image description here

based on my observation, any Case created or updated based on the parameter get from outside and pass through public site will automatically assign to site user first before trigger assignment rule. Exception only happen when I use Salesforce debug mode, In debug mode I can locally direct call related fuction and pass parameter do it. then Case update successful and assignment rule not trigger. this is because this Case owner remain the same user and no need go to ->site user->Case queue->user again.

Can someone cofirm my observation, and someone also can tell me how to stop assigment rule auto fire even got no code to trigger it.

  • For the Case sObject, the assignmentRuleID DML option can be set only from the API and is ignored when set from Apex. – Ashwani Apr 29 '16 at 7:10
  • May I ask, what do you mean "assignmentRuleID DML option can be set only from the API"? I develop my code in Force.com developer console – Jen Apr 29 '16 at 7:16
  • This would help you: developer.salesforce.com/docs/atlas.en-us.apexcode.meta/… – Ashwani Apr 29 '16 at 7:18
  • based on my observation, any Case created or updated based on the parameter get from outside Salesforce and pass through public site will automatically assign to site user first before trigger assignment rule. what I'm mention above is correct or wrong? can I assign new or updated Case to other user first by skipping the site user? – Jen Apr 29 '16 at 8:09
  • Jen, no you can not assign. All records created through public salesforce site have owner site guest user. – Ashwani Apr 29 '16 at 8:13
1

any Case created or updated based on the parameter get from outside Salesforce and pass through public site will automatically assign to site user first. Assignment rule not trigger for the Case sObject, the assignmentRuleID DML option can be set only from the API and is ignored when set from Apex.

|improve this answer|||||

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.