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
Mugdha RalegaonkarMugdha Ralegaonkar 

case assignment rule is getting fired when case comment is added from API

We have setup assignment rules and also setup default case owner from support settings. We are adding case comments through REST API call from external system and whenever case commet is added, it is resetting the case owner of the case by firing the assignment rules. If an agent has aready taken ownership of the case , when comment is added that ownership goes back to the queue as per the assignment rules and it is not helpful. I learnt that whenever API call takes place it fires assignment rules thats how salesofrce works. So, 1. first workaround we tried creating a checkbox, setting it to false by default and adding condition in the assignment rule saying run the rules only when checkbox is false. And we are sending the checkbox vale as true ONLY when comment is added from the API so that way assignment rules won't work. --> It did not work, although the value is coming as true, assignment rules still fires (As per sfdc standard behaviour) and it doesnt meet any of the rule criteria so it assigns default case owner defined in support settings.

second workaround we tried is uisng the trigger before inserting the case comment and setting the rule to false using below code. after activating the trigger, and testing the scenario.. the owner is still getting replaced when comment is added. Any suggestion would be of GREAT HELP!!

trigger test on CaseComment (before insert) {

List cc = new list();

for (CaseComment cd : Trigger.new) { Database.DMLOptions dmo = new Database.DMLOptions(); dmo.assignmentRuleHeader.useDefaultRule = false; cd.setoptions(dmo); cc.add(cd); }

insert cc; }

Thanks!!
Best Answer chosen by Mugdha Ralegaonkar
Andy BoettcherAndy Boettcher
There is a similar header on the REST API - https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_autoassign.htm

All Answers

Andy BoettcherAndy Boettcher
There is a similar header on the REST API - https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/headers_autoassign.htm
This was selected as the best answer
Mugdha RalegaonkarMugdha Ralegaonkar
Thanks Andy.
How should I use Sforce-Auto-Assign: FALSE in the code?
I am not expert in writing triggers yet, so had to ask.
Andy BoettcherAndy Boettcher
That Sforce-Auto-Assign header is going to be in whatever external system is pushing data to your org via the REST API, not within Salesforce itself.
Mugdha RalegaonkarMugdha Ralegaonkar
Hi! Thanx for your post. I have a question, so if I am using REST API in order for me to add a header to my httpPost I will need to make that post to some @Path  like:
HttpPost httppost = new HttpPost(environmentId + "/services/data/v33.0/sobjects/Case/"+ caseId);
httppost.setHeader("Sforce-Auto-Assign", false);

Is this will work ?
Thanx
Mugdha RalegaonkarMugdha Ralegaonkar
It worked!! Thanks!