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
Maximiliano ValinMaximiliano Valin 

How is the procedure to take ownership of a case using the API, if it is possible using python and simple_salesforce

Hello, I'm using the python module simple_salesforce to do some queries against Salesforce. Now I want to move forward doing some updates.

I'd like to do an automation process for taking ownership of a case, I tried to take ownership of a case, but when I did by using this piece of code:
sf = simple_salesforce.Salesforce(
    username='username',
    password='password',
    security_token='token',
    domain='test')
sf.Case.update('CASE_ID', {'OwnerId': 'USER_ID'})

In some way, it worked because the information in the case for Case Team, Department, Manager, Team Lead were changed to the ones belonging to the user, but the field for Case Owner was set for a different information, but not the user that I have set, the only that I figure out, is that the case was previously assigned to a queue not a user, and maybe I have to set another field also, because the Case Onwer changed to another queue, not the user that I want.

Please if anyone has some information that could help me please let me know.

Regards
Maximiliano
NagendraNagendra (Salesforce Developers) 
Hi Valin,

Sorry for this issue you are encountering.

Please check with below links which have real good information on how to update records in salesforce using python.
  • http://tomhayden3.com/2013/08/04/salesforce-python/
  • http://stackoverflow.com/questions/22214954/beatbox-python-having-issues-updating-multiple-records-in-salesforce
Please let us know if you are looking for something else.

For more information please check with below link.
Kindly mark this as solved if the information helps so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Best Regards,
Nagendra.
Maximiliano ValinMaximiliano Valin
Thank you for your answer Nagendra.

I know how to do updates using simple_salesforce, you gave me another option using beatbox, which I  have already tested, but my question pinpoint to the steps needed to take ownership of a case, that means which would be the database updates needed to reflect the same behavior that using the button Take ownership on the Salesforce web, or modify the owner to a user.

Do you know more about the database design, to help on this?

Regards
Maximiliano
Maximiliano ValinMaximiliano Valin
Just in case anyone needs, this is the way that we figured out to take ownership of a case using simple_salesforce:
headers = {'Sforce-Auto-Assign': 'False'}
sf.Case.update(case_id, {'OwnerId': user_id}, raw_response=True, headers=headers)

Regards
Maximiliano