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
salesforce1#salesforce1# 

How can I change owner for multiple cases at once

Hi

 

How can I change owner for multiple cases at once

 

for ex ramu--->ravi

 

Regards.

Ankit AroraAnkit Arora

Write a apex class

 

1) Fetch all cases with owner "ramu" (from your example) in a list

2) Then execute a for loop which will change the owner from "ramu" to "ravi"

3) Update that list.

 

Let me know if there is any problem in this approach.

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page

salesforce1#salesforce1#
Hi

can you give me a sample code.

regards...
Shailesh DeshpandeShailesh Deshpande
If you have transfer cases and transer record permission you can do it in a much simpler way using the list views. Below is the link:

http://login.salesforce.com/help/doc/en/cases_massaction.htm
HariPHariP
This is to give you basic idea of how to update cases with new owner. Hope this helps:

list<Case> tempCases = new list<Case>();
string oldOwnerId = '500abcd'; //use query to get the owner id;
string newOwnerId = '500xyz'; //use query to get new owner id;
for (Case c:[SELECT Id, OwnerId FROM Case WHERE OwnerId = :oldOwnerId) {
    c.OwnerId = newOwnerId;
    tempCases.add(c);
}
if (tempCases.size() > 0)
    update tempCases;

Thanks