+ Start a Discussion
cooldamselcooldamsel 

[URGENT!!!]Salesforce API Integration to update Case

Hi All,

I have created a WCF service to update a case in Salesforce. My service is working fine and updating the case in Salesforce. I am updating ony the status field in Case but the Case owner is also getting updated. I am not sure of the reason why the owner is updated. My logic is also that am including only the status field and I have not included the owner field. Please advise me on this.

Thanks in advance.
Best Answer chosen by cooldamsel
Mahesh DMahesh D
Please look into it

For the Case sObject, the assignmentRuleID DML option can be set only from the API and is ignored when set from Apex. For example, you can set the assignmentRuleID for an active or inactive rule from theexecuteanonymous() API call, but not from the Developer Console. This doesn’t apply to leads—theassignmentRuleID DML option can be set for leads from both Apex and the API.

Source is:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Database_AssignmentRuleHeader.htm

Please let me know if it helps you.

Regards,
Mahesh

All Answers

Pankaj_GanwaniPankaj_Ganwani
Hi,

Just check if there is any existing trigger or workflow rule on Case which gets fired after updating status field value.
Mahesh DMahesh D
Hi Cooldamesel,

You can troubleshoot it like below:

--> Try to update any other field from UI and see whether the Owner is changing or not.
    If Yes, then we can confirm that it is changing whenever you modify the Case.
--> Try changing the Status from UI and see whether Owner is changing or not.
    If Yes, then it is behaving same like Integration.

Once you have answer for above, like Pankaj said, you can verify if there any Workflow with field update or any before update trigger on the Case object exists or not.

Regards,
Mahesh
cooldamselcooldamsel
Hi Pankaj & Mahesh,

I checked the both ways with different user in UI but the account owner was not changed. I even checked for if there is an existing trigger or workflow but there was nothing available.

Thanks in advance.
Mahesh DMahesh D
Hi Cooldamsel,

Please check the Active Assignment rules on the Case object.

Regards,
Mahesh
Mahesh DMahesh D
Please look into it

For the Case sObject, the assignmentRuleID DML option can be set only from the API and is ignored when set from Apex. For example, you can set the assignmentRuleID for an active or inactive rule from theexecuteanonymous() API call, but not from the Developer Console. This doesn’t apply to leads—theassignmentRuleID DML option can be set for leads from both Apex and the API.

Source is:

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_Database_AssignmentRuleHeader.htm

Please let me know if it helps you.

Regards,
Mahesh
This was selected as the best answer
cooldamselcooldamsel
Hi Mahesh,

Thank you so much. It was the assignment rule updating the owner. I have deactivated the assignment rule and it was workig fine. But i am not able to check which assignment rule criteria is updating the owner. Could you please suggest how to solve this.

Thanks in advance.
Mahesh DMahesh D
Hi Cooldamsel,

We have to go through each rule entry and identify which is satisfying the condition and change accordingly.

Regards,
Mahesh
cooldamselcooldamsel
Hi Mahesh,

I have checked for all the criteria but none of them matches my scenario. I even updated one rule criteria to not update the owner. Anyways thanks for resolving the issue.
cooldamselcooldamsel
Hi Mahesh,

I have created a new criteria that executes first and checked if it is from WCF service. Then it was not assigned to any user and i checked on the 'Do not reassign owner' checkbox. This solved my issue.